Package org.testng
Class TestRunner
java.lang.Object
org.testng.TestRunner
- All Implemented Interfaces:
IAttributes,IConfigEavesdropper,ITestResultNotifier,ITestContext,IThreadWorkerFactory<ITestNGMethod>
public class TestRunner
extends Object
implements ITestContext, ITestResultNotifier, IThreadWorkerFactory<ITestNGMethod>, IConfigEavesdropper
This class takes care of running one Test.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsModifierConstructorDescriptionTestRunner(IConfiguration configuration, ISuite suite, XmlTest test, boolean skipFailedInvocationCounts, Collection<IInvokedMethodListener> invokedMethodListeners, List<IClassListener> classListeners) TestRunner(IConfiguration configuration, ISuite suite, XmlTest test, boolean skipFailedInvocationCounts, Collection<IInvokedMethodListener> invokedMethodListeners, List<IClassListener> classListeners, Comparator<ITestNGMethod> comparator) protectedTestRunner(IConfiguration configuration, ISuite suite, XmlTest test, String outputDirectory, IAnnotationFinder finder, boolean skipFailedInvocationCounts, Collection<IInvokedMethodListener> invokedMethodListeners, List<IClassListener> classListeners, Comparator<ITestNGMethod> comparator, DataProviderHolder otherHolder) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFailedButWithinSuccessPercentageTest(ITestNGMethod testMethod, ITestResult result) voidaddFailedTest(ITestNGMethod testMethod, ITestResult result) voidaddGuiceModule(com.google.inject.Module module) This method stands deprecated as of TestNG7.3.0voidaddInjector(List<com.google.inject.Module> moduleInstances, com.google.inject.Injector injector) This method stands deprecated as of TestNG7.3.0voidaddListener(ITestNGListener listener) voidaddPassedTest(ITestNGMethod tm, ITestResult tr) voidaddSkippedTest(ITestNGMethod tm, ITestResult tr) createWorkers(List<ITestNGMethod> methods) Create a list of workers to run the methods passed in parameter.List<com.google.inject.Module>This method stands deprecated as of TestNG7.3.0getAttribute(String name) String[]List<com.google.inject.Module>getGuiceModules(Class<? extends com.google.inject.Module> cls) This method stands deprecated as of TestNG7.3.0getHost()String[]com.google.inject.InjectorgetInjector(List<com.google.inject.Module> moduleInstances) This method stands deprecated as of TestNG7.3.0com.google.inject.InjectorgetInjector(IClass iClass) This method stands deprecated as of TestNG7.3.0getName()getSuite()getTest()static intremoveAttribute(String name) Remove the attributevoidrun()The main entry method for TestRunner.voidsetAttribute(String name, Object value) Set a custom attribute.voidvoidsetTestName(String name) voidsetVerbose(int n) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.testng.internal.ITestResultNotifier
addInvokedMethod
-
Constructor Details
-
TestRunner
protected TestRunner(IConfiguration configuration, ISuite suite, XmlTest test, String outputDirectory, IAnnotationFinder finder, boolean skipFailedInvocationCounts, Collection<IInvokedMethodListener> invokedMethodListeners, List<IClassListener> classListeners, Comparator<ITestNGMethod> comparator, DataProviderHolder otherHolder) -
TestRunner
public TestRunner(IConfiguration configuration, ISuite suite, XmlTest test, boolean skipFailedInvocationCounts, Collection<IInvokedMethodListener> invokedMethodListeners, List<IClassListener> classListeners, Comparator<ITestNGMethod> comparator) -
TestRunner
public TestRunner(IConfiguration configuration, ISuite suite, XmlTest test, boolean skipFailedInvocationCounts, Collection<IInvokedMethodListener> invokedMethodListeners, List<IClassListener> classListeners)
-
-
Method Details
-
getInvoker
-
getBeforeSuiteMethods
-
getAfterSuiteMethods
-
getBeforeTestConfigurationMethods
-
getAfterTestConfigurationMethods
-
getTestClasses
-
setTestName
-
setOutputDirectory
-
run
public void run()The main entry method for TestRunner.This is where all the hard work is done: - Invoke configuration methods - Invoke test methods - Catch exceptions - Collect results - Invoke listeners - etc...
-
createWorkers
Create a list of workers to run the methods passed in parameter. Each test method is run in its own worker except in the following cases: - The method belongs to a class that has @Test(sequential=true) - The parallel attribute is set to "classes" In both these cases, all the methods belonging to that class will then be put in the same worker in order to run in the same thread.- Specified by:
createWorkersin interfaceIThreadWorkerFactory<ITestNGMethod>- Parameters:
methods- tasks that need to be executed- Returns:
- list of workers
-
getName
- Specified by:
getNamein interfaceITestContext- Returns:
- The name of this test.
-
getStartDate
- Specified by:
getStartDatein interfaceITestContext- Returns:
- Returns the startDate.
-
getEndDate
- Specified by:
getEndDatein interfaceITestContext- Returns:
- Returns the endDate.
-
getPassedTests
- Specified by:
getPassedTestsin interfaceITestContext- Returns:
- A list of all the tests that run successfully.
-
getSkippedTests
- Specified by:
getSkippedTestsin interfaceITestContext- Returns:
- A list of all the tests that were skipped
-
getFailedTests
- Specified by:
getFailedTestsin interfaceITestContext- Returns:
- A map of all the tests that passed, indexed by their ITextMethor.
- See Also:
-
getFailedButWithinSuccessPercentageTests
- Specified by:
getFailedButWithinSuccessPercentageTestsin interfaceITestContext- Returns:
- A list of all the tests that failed but are being ignored because annotated with a successPercentage.
-
getIncludedGroups
- Specified by:
getIncludedGroupsin interfaceITestContext- Returns:
- All the groups that are included for this test run.
-
getExcludedGroups
- Specified by:
getExcludedGroupsin interfaceITestContext- Returns:
- All the groups that are excluded for this test run.
-
getOutputDirectory
- Specified by:
getOutputDirectoryin interfaceITestContext- Returns:
- Where the reports will be generated.
-
getSuite
- Specified by:
getSuitein interfaceITestContext- Returns:
- Returns the suite.
-
getAllTestMethods
- Specified by:
getAllTestMethodsin interfaceITestContext- Returns:
- All the test methods that were run.
-
getHost
- Specified by:
getHostin interfaceITestContext- Returns:
- The host where this test was run, or null if it was run locally. The returned string has the form: host:port
-
getExcludedMethods
- Specified by:
getExcludedMethodsin interfaceITestContext- Returns:
- All the methods that were not included in this test run.
-
getFailedConfigurations
- Specified by:
getFailedConfigurationsin interfaceITestContext- Returns:
- The information about the failed configuration method invocations.
- See Also:
-
getConfigurationsScheduledForInvocation
- Specified by:
getConfigurationsScheduledForInvocationin interfaceIConfigEavesdropper
-
getPassedConfigurations
- Specified by:
getPassedConfigurationsin interfaceITestContext- Returns:
- The information about the successful configuration method invocations.
- See Also:
-
getSkippedConfigurations
- Specified by:
getSkippedConfigurationsin interfaceITestContext- Returns:
- The information about the skipped configuration method invocations.
- See Also:
-
addPassedTest
- Specified by:
addPassedTestin interfaceITestResultNotifier
-
getPassedTests
- Specified by:
getPassedTestsin interfaceITestResultNotifier
-
getFailedTests
- Specified by:
getFailedTestsin interfaceITestResultNotifier
-
getSkippedTests
- Specified by:
getSkippedTestsin interfaceITestResultNotifier
-
addSkippedTest
- Specified by:
addSkippedTestin interfaceITestResultNotifier
-
addFailedTest
- Specified by:
addFailedTestin interfaceITestResultNotifier
-
addFailedButWithinSuccessPercentageTest
- Specified by:
addFailedButWithinSuccessPercentageTestin interfaceITestResultNotifier
-
getTest
- Specified by:
getTestin interfaceITestResultNotifier
-
getTestListeners
- Specified by:
getTestListenersin interfaceITestResultNotifier
-
getConfigurationListeners
- Specified by:
getConfigurationListenersin interfaceITestResultNotifier
-
getVerbose
public static int getVerbose() -
setVerbose
public void setVerbose(int n) -
addListener
-
getCurrentXmlTest
- Specified by:
getCurrentXmlTestin interfaceITestContext- Returns:
- the current XmlTest.
-
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
-
getGuiceModules
public List<com.google.inject.Module> getGuiceModules(Class<? extends com.google.inject.Module> cls) Description copied from interface:ITestContextThis method stands deprecated as of TestNG7.3.0- Specified by:
getGuiceModulesin interfaceITestContext
-
getAllGuiceModules
Description copied from interface:ITestContextThis method stands deprecated as of TestNG7.3.0- Specified by:
getAllGuiceModulesin interfaceITestContext
-
addGuiceModule
public void addGuiceModule(com.google.inject.Module module) Description copied from interface:ITestContextThis method stands deprecated as of TestNG7.3.0- Specified by:
addGuiceModulein interfaceITestContext
-
getInjector
Description copied from interface:ITestContextThis method stands deprecated as of TestNG7.3.0- Specified by:
getInjectorin interfaceITestContext
-
getInjector
Description copied from interface:ITestContextThis method stands deprecated as of TestNG7.3.0- Specified by:
getInjectorin interfaceITestContext
-
addInjector
public void addInjector(List<com.google.inject.Module> moduleInstances, com.google.inject.Injector injector) Description copied from interface:ITestContextThis method stands deprecated as of TestNG7.3.0- Specified by:
addInjectorin interfaceITestContext
-
getInjectorFactory
- Specified by:
getInjectorFactoryin interfaceITestContext
-