public class TestRunner extends java.lang.Object implements ITestContext, ITestResultNotifier, IThreadWorkerFactory<ITestNGMethod>
Modifier and Type | Class and Description |
---|---|
private class |
TestRunner.ConfigurationListener |
static class |
TestRunner.PriorityWeight |
Modifier and Type | Field and Description |
---|---|
private java.util.Comparator<ITestNGMethod> |
comparator |
private static java.lang.String |
DEFAULT_PROP_OUTPUT_DIR |
private GuiceHelper |
guiceHelper |
private static Logger |
LOGGER |
private ITestNGMethod[] |
m_afterSuiteMethods |
private ITestNGMethod[] |
m_afterXmlTestMethods |
private ITestNGMethod[] |
m_allTestMethods
All the test methods we found, associated with their respective classes.
|
private IAnnotationFinder |
m_annotationFinder |
private IAttributes |
m_attributes |
private ITestNGMethod[] |
m_beforeSuiteMethods |
private ITestNGMethod[] |
m_beforeXmlTestMethods |
private java.util.Map<java.lang.Class<? extends IClassListener>,IClassListener> |
m_classListeners |
private java.util.Map<java.lang.Class<?>,ITestClass> |
m_classMap
A map to keep track of Class <-> IClass.
|
private ClassMethodMap |
m_classMethodMap |
private IConfiguration |
m_configuration |
private java.util.Set<IConfigurationListener> |
m_configurationListeners |
private IConfigurationListener |
m_confListener |
private java.util.Map<java.lang.Class<? extends IDataProviderListener>,IDataProviderListener> |
m_dataProviderListeners |
private java.util.Date |
m_endDate |
private java.util.List<ITestNGMethod> |
m_excludedMethods |
private IResultMap |
m_failedButWithinSuccessPercentageTests |
private IResultMap |
m_failedConfigurations |
private IResultMap |
m_failedTests |
private ConfigurationGroupMethods |
m_groupMethods |
private ListMultiMap<java.lang.Class<? extends com.google.inject.Module>,com.google.inject.Module> |
m_guiceModules |
private java.lang.String |
m_host |
private java.util.Map<java.util.List<com.google.inject.Module>,com.google.inject.Injector> |
m_injectors |
private java.util.Collection<IInvokedMethodListener> |
m_invokedMethodListeners |
private java.util.Collection<IInvokedMethod> |
m_invokedMethods |
private IInvoker |
m_invoker |
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
m_metaGroups |
private java.util.List<IMethodInterceptor> |
m_methodInterceptors |
private java.lang.String |
m_outputDirectory
Where the reports will be created.
|
private IResultMap |
m_passedConfigurations |
private IResultMap |
m_passedTests |
private RunInfo |
m_runInfo |
private IResultMap |
m_skippedConfigurations |
private IResultMap |
m_skippedTests |
private java.util.Date |
m_startDate |
private ISuite |
m_suite |
private java.util.List<XmlClass> |
m_testClassesFromXml |
private TestNGClassFinder |
m_testClassFinder |
private java.util.List<ITestListener> |
m_testListeners
ITestListeners support.
|
private java.lang.String |
m_testName |
private static int |
m_verbose |
private XmlMethodSelector |
m_xmlMethodSelector |
private XmlTest |
m_xmlTest |
private java.util.Set<IExecutionVisualiser> |
visualisers |
Modifier | Constructor and Description |
---|---|
|
TestRunner(IConfiguration configuration,
ISuite suite,
XmlTest test,
boolean skipFailedInvocationCounts,
java.util.Collection<IInvokedMethodListener> invokedMethodListeners,
java.util.List<IClassListener> classListeners)
This constructor is used by testng-remote, any changes related to it please contact with
testng-team.
|
|
TestRunner(IConfiguration configuration,
ISuite suite,
XmlTest test,
boolean skipFailedInvocationCounts,
java.util.Collection<IInvokedMethodListener> invokedMethodListeners,
java.util.List<IClassListener> classListeners,
java.util.Comparator<ITestNGMethod> comparator) |
protected |
TestRunner(IConfiguration configuration,
ISuite suite,
XmlTest test,
java.lang.String outputDirectory,
IAnnotationFinder finder,
boolean skipFailedInvocationCounts,
java.util.Collection<IInvokedMethodListener> invokedMethodListeners,
java.util.List<IClassListener> classListeners,
java.util.Comparator<ITestNGMethod> comparator,
java.util.Map<java.lang.Class<? extends IDataProviderListener>,IDataProviderListener> dataProviderListeners) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
addConfigurationListener(IConfigurationListener icl) |
void |
addFailedButWithinSuccessPercentageTest(ITestNGMethod testMethod,
ITestResult result) |
void |
addFailedTest(ITestNGMethod testMethod,
ITestResult result) |
void |
addInjector(java.util.List<com.google.inject.Module> moduleInstances,
com.google.inject.Injector injector) |
void |
addInvokedMethod(InvokedMethod im) |
void |
addListener(ITestNGListener listener) |
private void |
addMetaGroup(java.lang.String name,
java.util.List<java.lang.String> groupNames) |
(package private) void |
addMethodInterceptor(IMethodInterceptor methodInterceptor) |
void |
addPassedTest(ITestNGMethod tm,
ITestResult tr) |
void |
addSkippedTest(ITestNGMethod tm,
ITestResult tr) |
(package private) void |
addTestListener(ITestListener listener) |
private void |
afterRun() |
private void |
beforeRun()
Before run preparements.
|
private java.util.Map<java.lang.String,java.lang.String> |
createGroups(java.util.List<java.lang.String> groups) |
java.util.List<IWorker<ITestNGMethod>> |
createWorkers(java.util.List<ITestNGMethod> methods)
Create a list of workers to run the methods passed in parameter.
|
private void |
dumpInvokedMethods() |
private void |
fireEvent(boolean isStart)
Trigger the start/finish event.
|
ITestNGMethod[] |
getAfterSuiteMethods() |
ITestNGMethod[] |
getAfterTestConfigurationMethods() |
private java.util.List<XmlPackage> |
getAllPackages()
Returns all packages to use for the current test.
|
ITestNGMethod[] |
getAllTestMethods() |
java.lang.Object |
getAttribute(java.lang.String name) |
java.util.Set<java.lang.String> |
getAttributeNames() |
ITestNGMethod[] |
getBeforeSuiteMethods() |
ITestNGMethod[] |
getBeforeTestConfigurationMethods() |
java.util.List<IConfigurationListener> |
getConfigurationListeners() |
XmlTest |
getCurrentXmlTest() |
java.util.Date |
getEndDate()
When this test stopped running.
|
java.lang.String[] |
getExcludedGroups() |
java.util.Collection<ITestNGMethod> |
getExcludedMethods() |
IResultMap |
getFailedButWithinSuccessPercentageTests() |
IResultMap |
getFailedConfigurations()
Retrieves information about the failed configuration method invocations.
|
IResultMap |
getFailedTests() |
java.util.Set<ITestResult> |
getFailedTests(ITestNGMethod tm) |
java.util.List<com.google.inject.Module> |
getGuiceModules(java.lang.Class<? extends com.google.inject.Module> cls) |
java.lang.String |
getHost() |
java.lang.String[] |
getIncludedGroups() |
com.google.inject.Injector |
getInjector(IClass iClass) |
com.google.inject.Injector |
getInjector(java.util.List<com.google.inject.Module> moduleInstances) |
java.util.List<ITestNGMethod> |
getInvokedMethods() |
IInvoker |
getInvoker() |
java.lang.String |
getName()
The name of this test.
|
java.lang.String |
getOutputDirectory() |
IResultMap |
getPassedConfigurations()
Retrieves information about the successful configuration method invocations.
|
IResultMap |
getPassedTests() |
java.util.Set<ITestResult> |
getPassedTests(ITestNGMethod tm) |
IResultMap |
getSkippedConfigurations()
Retrieves information about the skipped configuration method invocations.
|
IResultMap |
getSkippedTests() |
java.util.Set<ITestResult> |
getSkippedTests(ITestNGMethod tm) |
java.util.Date |
getStartDate()
When this test started running.
|
ISuite |
getSuite() |
XmlTest |
getTest() |
java.util.Collection<ITestClass> |
getTestClasses() |
java.util.List<ITestListener> |
getTestListeners() |
static int |
getVerbose() |
private void |
init() |
private void |
init(IConfiguration configuration,
ISuite suite,
XmlTest test,
java.lang.String outputDirectory,
IAnnotationFinder annotationFinder,
boolean skipFailedInvocationCounts,
java.util.Collection<IInvokedMethodListener> invokedMethodListeners,
java.util.List<IClassListener> classListeners) |
private void |
initListeners() |
private void |
initMetaGroups(XmlTest xmlTest)
Initialize meta groups
|
private void |
initMethods() |
private void |
initRunInfo(XmlTest xmlTest) |
private ITestNGMethod[] |
intercept(ITestNGMethod[] methods)
Apply the method interceptor (if applicable) to the list of methods.
|
private void |
invokeTestConfigurations(ITestNGMethod[] testConfigurationMethods) |
private static void |
log(java.lang.String s) |
private void |
logFailedTest(ITestNGMethod method,
ITestResult tr,
boolean withinSuccessPercentage) |
private void |
logStart()
Logs the beginning of the
beforeRun() . |
private static java.util.Comparator<ITestNGMethod> |
newComparator(boolean needPrioritySort) |
private static java.util.concurrent.BlockingQueue<java.lang.Runnable> |
newQueue(boolean needPrioritySort) |
private void |
privateRun(XmlTest xmlTest)
Main method that create a graph of methods and then pass it to the graph executor to run them.
|
private void |
privateRunJUnit() |
java.lang.Object |
removeAttribute(java.lang.String name)
Remove the attribute
|
void |
run()
The main entry method for TestRunner.
|
private void |
runJUnitWorkers(java.util.List<? extends IWorker<ITestNGMethod>> workers) |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Set a custom attribute.
|
void |
setOutputDirectory(java.lang.String od) |
void |
setTestName(java.lang.String name) |
void |
setVerbose(int n) |
private boolean |
sortOnPriority(ITestNGMethod[] interceptedOrder) |
private static final java.lang.String DEFAULT_PROP_OUTPUT_DIR
private static final Logger LOGGER
private final java.util.Comparator<ITestNGMethod> comparator
private ISuite m_suite
private XmlTest m_xmlTest
private java.lang.String m_testName
private final GuiceHelper guiceHelper
private java.util.List<XmlClass> m_testClassesFromXml
private IInvoker m_invoker
private IAnnotationFinder m_annotationFinder
private java.util.List<ITestListener> m_testListeners
private java.util.Set<IConfigurationListener> m_configurationListeners
private final java.util.Set<IExecutionVisualiser> visualisers
private IConfigurationListener m_confListener
private java.util.Collection<IInvokedMethodListener> m_invokedMethodListeners
private final java.util.Map<java.lang.Class<? extends IClassListener>,IClassListener> m_classListeners
private final java.util.Map<java.lang.Class<? extends IDataProviderListener>,IDataProviderListener> m_dataProviderListeners
private ITestNGMethod[] m_allTestMethods
private java.util.Date m_startDate
private java.util.Date m_endDate
private java.util.Map<java.lang.Class<?>,ITestClass> m_classMap
private java.lang.String m_outputDirectory
private XmlMethodSelector m_xmlMethodSelector
private static int m_verbose
private ITestNGMethod[] m_beforeSuiteMethods
private ITestNGMethod[] m_afterSuiteMethods
private ITestNGMethod[] m_beforeXmlTestMethods
private ITestNGMethod[] m_afterXmlTestMethods
private java.util.List<ITestNGMethod> m_excludedMethods
private ConfigurationGroupMethods m_groupMethods
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> m_metaGroups
private IResultMap m_passedTests
private IResultMap m_failedTests
private IResultMap m_failedButWithinSuccessPercentageTests
private IResultMap m_skippedTests
private RunInfo m_runInfo
private java.lang.String m_host
private java.util.List<IMethodInterceptor> m_methodInterceptors
private ClassMethodMap m_classMethodMap
private TestNGClassFinder m_testClassFinder
private IConfiguration m_configuration
private final java.util.Collection<IInvokedMethod> m_invokedMethods
private IResultMap m_passedConfigurations
private IResultMap m_skippedConfigurations
private IResultMap m_failedConfigurations
private IAttributes m_attributes
private ListMultiMap<java.lang.Class<? extends com.google.inject.Module>,com.google.inject.Module> m_guiceModules
private java.util.Map<java.util.List<com.google.inject.Module>,com.google.inject.Injector> m_injectors
protected TestRunner(IConfiguration configuration, ISuite suite, XmlTest test, java.lang.String outputDirectory, IAnnotationFinder finder, boolean skipFailedInvocationCounts, java.util.Collection<IInvokedMethodListener> invokedMethodListeners, java.util.List<IClassListener> classListeners, java.util.Comparator<ITestNGMethod> comparator, java.util.Map<java.lang.Class<? extends IDataProviderListener>,IDataProviderListener> dataProviderListeners)
public TestRunner(IConfiguration configuration, ISuite suite, XmlTest test, boolean skipFailedInvocationCounts, java.util.Collection<IInvokedMethodListener> invokedMethodListeners, java.util.List<IClassListener> classListeners, java.util.Comparator<ITestNGMethod> comparator)
public TestRunner(IConfiguration configuration, ISuite suite, XmlTest test, boolean skipFailedInvocationCounts, java.util.Collection<IInvokedMethodListener> invokedMethodListeners, java.util.List<IClassListener> classListeners)
private void init(IConfiguration configuration, ISuite suite, XmlTest test, java.lang.String outputDirectory, IAnnotationFinder annotationFinder, boolean skipFailedInvocationCounts, java.util.Collection<IInvokedMethodListener> invokedMethodListeners, java.util.List<IClassListener> classListeners)
private java.util.List<XmlPackage> getAllPackages()
public IInvoker getInvoker()
public ITestNGMethod[] getBeforeSuiteMethods()
public ITestNGMethod[] getAfterSuiteMethods()
public ITestNGMethod[] getBeforeTestConfigurationMethods()
public ITestNGMethod[] getAfterTestConfigurationMethods()
private void init()
private void initListeners()
private void initMetaGroups(XmlTest xmlTest)
private void initRunInfo(XmlTest xmlTest)
private void initMethods()
public java.util.Collection<ITestClass> getTestClasses()
public void setTestName(java.lang.String name)
public void setOutputDirectory(java.lang.String od)
private void addMetaGroup(java.lang.String name, java.util.List<java.lang.String> groupNames)
private java.util.Map<java.lang.String,java.lang.String> createGroups(java.util.List<java.lang.String> groups)
public void run()
This is where all the hard work is done: - Invoke configuration methods - Invoke test methods - Catch exceptions - Collect results - Invoke listeners - etc...
private void beforeRun()
private void invokeTestConfigurations(ITestNGMethod[] testConfigurationMethods)
private void privateRunJUnit()
private static java.util.Comparator<ITestNGMethod> newComparator(boolean needPrioritySort)
private boolean sortOnPriority(ITestNGMethod[] interceptedOrder)
private static java.util.concurrent.BlockingQueue<java.lang.Runnable> newQueue(boolean needPrioritySort)
private void privateRun(XmlTest xmlTest)
private ITestNGMethod[] intercept(ITestNGMethod[] methods)
public java.util.List<IWorker<ITestNGMethod>> createWorkers(java.util.List<ITestNGMethod> methods)
createWorkers
in interface IThreadWorkerFactory<ITestNGMethod>
methods
- tasks that need to be executedprivate void runJUnitWorkers(java.util.List<? extends IWorker<ITestNGMethod>> workers)
private void afterRun()
private void logStart()
beforeRun()
.private void fireEvent(boolean isStart)
isStart
- true if the event is for start, false if the event is for
finishpublic java.lang.String getName()
ITestContext
getName
in interface ITestContext
public java.util.Date getStartDate()
ITestContext
getStartDate
in interface ITestContext
public java.util.Date getEndDate()
ITestContext
getEndDate
in interface ITestContext
public IResultMap getPassedTests()
getPassedTests
in interface ITestContext
public IResultMap getSkippedTests()
getSkippedTests
in interface ITestContext
public IResultMap getFailedTests()
getFailedTests
in interface ITestContext
ITestNGMethod
public IResultMap getFailedButWithinSuccessPercentageTests()
getFailedButWithinSuccessPercentageTests
in interface ITestContext
public java.lang.String[] getIncludedGroups()
getIncludedGroups
in interface ITestContext
public java.lang.String[] getExcludedGroups()
getExcludedGroups
in interface ITestContext
public java.lang.String getOutputDirectory()
getOutputDirectory
in interface ITestContext
public ISuite getSuite()
getSuite
in interface ITestContext
public ITestNGMethod[] getAllTestMethods()
getAllTestMethods
in interface ITestContext
public java.lang.String getHost()
getHost
in interface ITestContext
public java.util.Collection<ITestNGMethod> getExcludedMethods()
getExcludedMethods
in interface ITestContext
public IResultMap getFailedConfigurations()
ITestContext
getFailedConfigurations
in interface ITestContext
ITestContext.getFailedConfigurations()
public IResultMap getPassedConfigurations()
ITestContext
getPassedConfigurations
in interface ITestContext
ITestContext.getPassedConfigurations()
public IResultMap getSkippedConfigurations()
ITestContext
getSkippedConfigurations
in interface ITestContext
ITestContext.getSkippedConfigurations()
public void addPassedTest(ITestNGMethod tm, ITestResult tr)
addPassedTest
in interface ITestResultNotifier
public java.util.Set<ITestResult> getPassedTests(ITestNGMethod tm)
getPassedTests
in interface ITestResultNotifier
public java.util.Set<ITestResult> getFailedTests(ITestNGMethod tm)
getFailedTests
in interface ITestResultNotifier
public java.util.Set<ITestResult> getSkippedTests(ITestNGMethod tm)
getSkippedTests
in interface ITestResultNotifier
public void addSkippedTest(ITestNGMethod tm, ITestResult tr)
addSkippedTest
in interface ITestResultNotifier
public void addInvokedMethod(InvokedMethod im)
addInvokedMethod
in interface ITestResultNotifier
public void addFailedTest(ITestNGMethod testMethod, ITestResult result)
addFailedTest
in interface ITestResultNotifier
public void addFailedButWithinSuccessPercentageTest(ITestNGMethod testMethod, ITestResult result)
addFailedButWithinSuccessPercentageTest
in interface ITestResultNotifier
public XmlTest getTest()
getTest
in interface ITestResultNotifier
public java.util.List<ITestListener> getTestListeners()
getTestListeners
in interface ITestResultNotifier
public java.util.List<IConfigurationListener> getConfigurationListeners()
getConfigurationListeners
in interface ITestResultNotifier
private void logFailedTest(ITestNGMethod method, ITestResult tr, boolean withinSuccessPercentage)
private static void log(java.lang.String s)
public static int getVerbose()
public void setVerbose(int n)
void addTestListener(ITestListener listener)
public void addListener(ITestNGListener listener)
void addConfigurationListener(IConfigurationListener icl)
private void dumpInvokedMethods()
public java.util.List<ITestNGMethod> getInvokedMethods()
void addMethodInterceptor(IMethodInterceptor methodInterceptor)
public XmlTest getCurrentXmlTest()
getCurrentXmlTest
in interface ITestContext
public java.lang.Object getAttribute(java.lang.String name)
getAttribute
in interface IAttributes
name
- The name of the attribute to returnpublic void setAttribute(java.lang.String name, java.lang.Object value)
IAttributes
setAttribute
in interface IAttributes
public java.util.Set<java.lang.String> getAttributeNames()
getAttributeNames
in interface IAttributes
public java.lang.Object removeAttribute(java.lang.String name)
IAttributes
removeAttribute
in interface IAttributes
public java.util.List<com.google.inject.Module> getGuiceModules(java.lang.Class<? extends com.google.inject.Module> cls)
getGuiceModules
in interface ITestContext
public com.google.inject.Injector getInjector(java.util.List<com.google.inject.Module> moduleInstances)
getInjector
in interface ITestContext
public com.google.inject.Injector getInjector(IClass iClass)
getInjector
in interface ITestContext
public void addInjector(java.util.List<com.google.inject.Module> moduleInstances, com.google.inject.Injector injector)
addInjector
in interface ITestContext