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 classThe default implementation ofITestRunnerFactory.private static classprivate class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IAttributesprivate final Map<Class<? extends IClassListener>, IClassListener> private IConfigurationprivate static final Stringprivate ITestListenerprivate final DataProviderHolderprivate Map<Class<? extends IInvokedMethodListener>, IInvokedMethodListener> private final Map<Class<? extends ISuiteListener>, ISuiteListener> private ITestObjectFactoryprivate Stringprivate com.google.inject.Injectorprivate Stringprivate Booleanprivate final Map<String, ISuiteResult> private final SuiteRunStateprivate final List<ITestListener> private final List<TestRunner> private ITestRunnerFactoryprivate booleanprivate final Set<IExecutionVisualiser> private XmlSuite -
Constructor Summary
ConstructorsModifierConstructorDescriptionSuiteRunner(IConfiguration configuration, XmlSuite suite, String outputDir, ITestRunnerFactory runnerFactory, boolean useDefaultListeners, Comparator<ITestNGMethod> comparator) protectedSuiteRunner(IConfiguration configuration, XmlSuite suite, String outputDir, ITestRunnerFactory runnerFactory, boolean useDefaultListeners, List<IMethodInterceptor> methodInterceptors, Collection<IInvokedMethodListener> invokedMethodListeners, SuiteRunner.TestListenersContainer container, 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) voidprotected voidaddListener(ISuiteListener reporter) voidaddListener(ITestNGListener listener) private voidaddReporter(IReporter listener) private voidaddVisualiser(IExecutionVisualiser visualiser) voidafterInvocation(IInvokedMethod method, ITestResult testResult) voidbeforeInvocation(IInvokedMethod method, ITestResult testResult) private ITestRunnerFactorybuildRunnerFactory(Comparator<ITestNGMethod> comparator) Returns the annotation finder for the given annotation type.getAttribute(String name) (package private) ITestListenergetHost()Retrieves the map of groups and their associated test methods.getName()getParameter(String parameterName) FIXME: should be removed?com.google.inject.InjectorRetrieves the shared state for a suite.private voidinit(IConfiguration configuration, XmlSuite suite, String outputDir, ITestRunnerFactory runnerFactory, boolean useDefaultListeners, List<IMethodInterceptor> methodInterceptors, Collection<IInvokedMethodListener> invokedMethodListener, SuiteRunner.TestListenersContainer container, Collection<IClassListener> classListeners, DataProviderHolder attribs, Comparator<ITestNGMethod> comparator) private voidinvokeListeners(boolean start) private voidremoveAttribute(String name) Remove the attributevoidrun()Triggers the start of running tests included in the suite.private voidImplement. private voidprivate voidrunTest(TestRunner tr) voidsetAttribute(String name, Object value) Set a custom attribute.voidvoidsetObjectFactory(ITestObjectFactory objectFactory) private voidsetOutputDir(String outputdir) voidsetParentInjector(com.google.inject.Injector injector) voidsetReportResults(boolean reportResults) voidsetSkipFailedInvocationCounts(Boolean skipFailedInvocationCounts) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.testng.IInvokedMethodListener
afterInvocation, beforeInvocationMethods inherited from interface org.testng.ISuite
getObjectFactory2
-
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
-
exitCodeListener
-
-
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, SuiteRunner.TestListenersContainer container, 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, SuiteRunner.TestListenersContainer container, Collection<IClassListener> classListeners, DataProviderHolder attribs, Comparator<ITestNGMethod> comparator) -
getXmlSuite
- Specified by:
getXmlSuitein interfaceISuite- Returns:
- The representation of the current XML suite file.
-
getName
-
setObjectFactory
-
setReportResults
public void setReportResults(boolean reportResults) -
getExitCodeListener
ITestListener getExitCodeListener() -
invokeListeners
private void invokeListeners(boolean start) -
setOutputDir
-
buildRunnerFactory
-
getParallel
- Specified by:
getParallelin interfaceISuite- Returns:
- true if the tests must be run in parallel.
-
getParentModule
- Specified by:
getParentModulein interfaceISuite
-
getGuiceStage
- Specified by:
getGuiceStagein interfaceISuite
-
getParentInjector
public com.google.inject.Injector getParentInjector()- Specified by:
getParentInjectorin interfaceISuite
-
setParentInjector
public void setParentInjector(com.google.inject.Injector injector) - Specified by:
setParentInjectorin interfaceISuite
-
run
public void run()Description copied from interface:ISuiteTriggers 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:
addListenerin interfaceISuite
-
getOutputDirectory
- Specified by:
getOutputDirectoryin interfaceISuite- Returns:
- The output directory used for the reports.
-
getResults
- Specified by:
getResultsin interfaceISuite- Returns:
- The results for this suite.
-
getParameter
FIXME: should be removed?- Specified by:
getParameterin 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:ISuiteRetrieves the map of groups and their associated test methods.- Specified by:
getMethodsByGroupsin 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:
getExcludedMethodsin interfaceISuite- Returns:
- All the methods that were not included in this test run.
- See Also:
-
getObjectFactory
- Specified by:
getObjectFactoryin interfaceISuite- Returns:
- The object factory used to create all test instances.
-
getAnnotationFinder
Returns the annotation finder for the given annotation type.- Specified by:
getAnnotationFinderin interfaceISuite- Returns:
- the annotation finder for the given annotation type.
-
setHost
-
getHost
-
getSuiteState
Description copied from interface:ISuiteRetrieves the shared state for a suite.- Specified by:
getSuiteStatein interfaceISuite- Returns:
- the share state of the current suite.
- See Also:
-
setSkipFailedInvocationCounts
-
getAttribute
- Specified by:
getAttributein interfaceIAttributes- Parameters:
name- The name of the attribute to return- Returns:
- The attribute
-
setAttribute
Description copied from interface:IAttributesSet a custom attribute.- Specified by:
setAttributein interfaceIAttributes- Parameters:
name- The attribute namevalue- The attribute value
-
getAttributeNames
- Specified by:
getAttributeNamesin interfaceIAttributes- Returns:
- all the attributes names.
-
removeAttribute
Description copied from interface:IAttributesRemove the attribute- Specified by:
removeAttributein interfaceIAttributes- Parameters:
name- The attribute name- Returns:
- the attribute value if found, null otherwise
-
afterInvocation
- Specified by:
afterInvocationin interfaceIInvokedMethodListener
-
beforeInvocation
- Specified by:
beforeInvocationin interfaceIInvokedMethodListener
-
getAllInvokedMethods
- Specified by:
getAllInvokedMethodsin interfaceISuite- Returns:
- a list of all the methods that were invoked in this suite.
-
getAllMethods
- Specified by:
getAllMethodsin 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.
-