Package org.testng
Class SuiteRunner
java.lang.Object
org.testng.SuiteRunner
- All Implemented Interfaces:
IAttributes
,IInvokedMethodListener
,ISuite
,ITestNGListener
SuiteRunner
is responsible for running all the tests included in one suite. The test
start is triggered by run()
method.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
The default implementation ofITestRunnerFactory
.private static class
private class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IAttributes
private final Map<Class<? extends IClassListener>,
IClassListener> private IConfiguration
private static final String
private final DataProviderHolder
private Map<Class<? extends IInvokedMethodListener>,
IInvokedMethodListener> private final Map<Class<? extends ISuiteListener>,
ISuiteListener> private ITestObjectFactory
private String
private com.google.inject.Injector
private String
private Boolean
private final Map<String,
ISuiteResult> private final SuiteRunState
private final List<ITestListener>
private final List<TestRunner>
private ITestRunnerFactory
private boolean
private final Set<IExecutionVisualiser>
private XmlSuite
-
Constructor Summary
ConstructorsModifierConstructorDescriptionSuiteRunner
(IConfiguration configuration, XmlSuite suite, String outputDir, ITestRunnerFactory runnerFactory, boolean useDefaultListeners, Comparator<ITestNGMethod> comparator) protected
SuiteRunner
(IConfiguration configuration, XmlSuite suite, String outputDir, ITestRunnerFactory runnerFactory, boolean useDefaultListeners, List<IMethodInterceptor> methodInterceptors, Collection<IInvokedMethodListener> invokedMethodListeners, Collection<ITestListener> testListeners, Collection<IClassListener> classListeners, DataProviderHolder holder, Comparator<ITestNGMethod> comparator) SuiteRunner
(IConfiguration configuration, XmlSuite suite, String outputDir, ITestRunnerFactory runnerFactory, Comparator<ITestNGMethod> comparator) -
Method Summary
Modifier and TypeMethodDescription(package private) void
protected void
addListener
(ISuiteListener reporter) void
addListener
(ITestNGListener listener) private void
addReporter
(IReporter listener) private void
addVisualiser
(IExecutionVisualiser visualiser) void
afterInvocation
(IInvokedMethod method, ITestResult testResult) void
beforeInvocation
(IInvokedMethod method, ITestResult testResult) private ITestRunnerFactory
buildRunnerFactory
(Comparator<ITestNGMethod> comparator) Returns the annotation finder for the given annotation type.getAttribute
(String name) getHost()
Retrieves the map of groups and their associated test methods.getName()
getParameter
(String parameterName) FIXME: should be removed?com.google.inject.Injector
Retrieves the shared state for a suite.private void
init
(IConfiguration configuration, XmlSuite suite, String outputDir, ITestRunnerFactory runnerFactory, boolean useDefaultListeners, List<IMethodInterceptor> methodInterceptors, Collection<IInvokedMethodListener> invokedMethodListener, Collection<ITestListener> testListeners, Collection<IClassListener> classListeners, DataProviderHolder attribs, Comparator<ITestNGMethod> comparator) private void
invokeListeners
(boolean start) static void
private void
removeAttribute
(String name) Remove the attributevoid
run()
Triggers the start of running tests included in the suite.private void
Implement. private void
private void
runTest
(TestRunner tr) void
setAttribute
(String name, Object value) Set a custom attribute.void
void
setObjectFactory
(ITestObjectFactory objectFactory) private void
setOutputDir
(String outputdir) void
setParentInjector
(com.google.inject.Injector injector) void
setReportResults
(boolean reportResults) void
setSkipFailedInvocationCounts
(Boolean skipFailedInvocationCounts) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.testng.IInvokedMethodListener
afterInvocation, beforeInvocation
-
Field Details
-
DEFAULT_OUTPUT_DIR
- See Also:
-
suiteResults
-
testRunners
-
listeners
-
outputDir
-
xmlSuite
-
parentInjector
private com.google.inject.Injector parentInjector -
testListeners
-
classListeners
-
tmpRunnerFactory
-
holder
-
useDefaultListeners
private boolean useDefaultListeners -
remoteHost
-
configuration
-
objectFactory
-
skipFailedInvocationCounts
-
reporters
-
invokedMethodListeners
-
suiteState
-
attributes
-
visualisers
-
-
Constructor Details
-
SuiteRunner
public SuiteRunner(IConfiguration configuration, XmlSuite suite, String outputDir, ITestRunnerFactory runnerFactory, Comparator<ITestNGMethod> comparator) -
SuiteRunner
public SuiteRunner(IConfiguration configuration, XmlSuite suite, String outputDir, ITestRunnerFactory runnerFactory, boolean useDefaultListeners, Comparator<ITestNGMethod> comparator) -
SuiteRunner
protected SuiteRunner(IConfiguration configuration, XmlSuite suite, String outputDir, ITestRunnerFactory runnerFactory, boolean useDefaultListeners, List<IMethodInterceptor> methodInterceptors, Collection<IInvokedMethodListener> invokedMethodListeners, Collection<ITestListener> testListeners, Collection<IClassListener> classListeners, DataProviderHolder holder, Comparator<ITestNGMethod> comparator)
-
-
Method Details
-
init
private void init(IConfiguration configuration, XmlSuite suite, String outputDir, ITestRunnerFactory runnerFactory, boolean useDefaultListeners, List<IMethodInterceptor> methodInterceptors, Collection<IInvokedMethodListener> invokedMethodListener, Collection<ITestListener> testListeners, Collection<IClassListener> classListeners, DataProviderHolder attribs, Comparator<ITestNGMethod> comparator) -
getXmlSuite
- Specified by:
getXmlSuite
in interfaceISuite
- Returns:
- The representation of the current XML suite file.
-
getName
-
setObjectFactory
-
setReportResults
public void setReportResults(boolean reportResults) -
invokeListeners
private void invokeListeners(boolean start) -
setOutputDir
-
buildRunnerFactory
-
getParallel
- Specified by:
getParallel
in interfaceISuite
- Returns:
- true if the tests must be run in parallel.
-
getParentModule
- Specified by:
getParentModule
in interfaceISuite
-
getGuiceStage
- Specified by:
getGuiceStage
in interfaceISuite
-
getParentInjector
public com.google.inject.Injector getParentInjector()- Specified by:
getParentInjector
in interfaceISuite
-
setParentInjector
public void setParentInjector(com.google.inject.Injector injector) - Specified by:
setParentInjector
in interfaceISuite
-
run
public void run()Description copied from interface:ISuite
Triggers the start of running tests included in the suite. -
privateRun
private void privateRun() -
addVisualiser
-
addReporter
-
addConfigurationListener
-
getReporters
-
getDataProviderListeners
-
runSequentially
private void runSequentially() -
runTest
-
runInParallelTestMode
private void runInParallelTestMode()Implement. Since this kind of parallelism happens at the suite level, we need a special code path to execute it. All the other parallelism strategies are implemented at the test level in TestRunner#createParallelWorkers (but since this method deals with just one <test> tag, it can't implement , which is why we're doing it here). -
addListener
- Parameters:
reporter
- The ISuiteListener interested in reporting the result of the current suite.
-
addListener
- Specified by:
addListener
in interfaceISuite
-
getOutputDirectory
- Specified by:
getOutputDirectory
in interfaceISuite
- Returns:
- The output directory used for the reports.
-
getResults
- Specified by:
getResults
in interfaceISuite
- Returns:
- The results for this suite.
-
getParameter
FIXME: should be removed?- Specified by:
getParameter
in interfaceISuite
- Parameters:
parameterName
- The name of the parameter- Returns:
- The value of this parameter, or null if none was specified.
- See Also:
-
getMethodsByGroups
Description copied from interface:ISuite
Retrieves the map of groups and their associated test methods.- Specified by:
getMethodsByGroups
in interfaceISuite
- Returns:
- A map where the key is the group and the value is a list of methods used by this group.
- See Also:
-
getExcludedMethods
- Specified by:
getExcludedMethods
in interfaceISuite
- Returns:
- All the methods that were not included in this test run.
- See Also:
-
getObjectFactory
- Specified by:
getObjectFactory
in interfaceISuite
- Returns:
- The object factory used to create all test instances.
-
getObjectFactory2
- Specified by:
getObjectFactory2
in interfaceISuite
-
getAnnotationFinder
Returns the annotation finder for the given annotation type.- Specified by:
getAnnotationFinder
in interfaceISuite
- Returns:
- the annotation finder for the given annotation type.
-
ppp
-
setHost
-
getHost
-
getSuiteState
Description copied from interface:ISuite
Retrieves the shared state for a suite.- Specified by:
getSuiteState
in interfaceISuite
- Returns:
- the share state of the current suite.
- See Also:
-
setSkipFailedInvocationCounts
-
getAttribute
- Specified by:
getAttribute
in interfaceIAttributes
- Parameters:
name
- The name of the attribute to return- Returns:
- The attribute
-
setAttribute
Description copied from interface:IAttributes
Set a custom attribute.- Specified by:
setAttribute
in interfaceIAttributes
- Parameters:
name
- The attribute namevalue
- The attribute value
-
getAttributeNames
- Specified by:
getAttributeNames
in interfaceIAttributes
- Returns:
- all the attributes names.
-
removeAttribute
Description copied from interface:IAttributes
Remove the attribute- Specified by:
removeAttribute
in interfaceIAttributes
- Parameters:
name
- The attribute name- Returns:
- the attribute value if found, null otherwise
-
afterInvocation
- Specified by:
afterInvocation
in interfaceIInvokedMethodListener
-
beforeInvocation
- Specified by:
beforeInvocation
in interfaceIInvokedMethodListener
-
getAllInvokedMethods
- Specified by:
getAllInvokedMethods
in interfaceISuite
- Returns:
- a list of all the methods that were invoked in this suite.
-
getAllMethods
- Specified by:
getAllMethods
in interfaceISuite
- Returns:
- the total number of methods found in this suite. The presence of factories or data providers might cause the actual number of test methods run be bigger than this list.
-