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, Comparator<ITestNGMethod> comparator, ISuiteRunnerListener suiteRunner) TestRunner
(IConfiguration configuration, ISuite suite, XmlTest test, boolean skipFailedInvocationCounts, Collection<IInvokedMethodListener> invokedMethodListeners, List<IClassListener> classListeners, ISuiteRunnerListener suiteRunner) 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, ISuiteRunnerListener suiteRunner) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFailedButWithinSuccessPercentageTest
(ITestNGMethod testMethod, ITestResult result) void
addFailedTest
(ITestNGMethod testMethod, ITestResult result) void
addListener
(ITestNGListener listener) void
addPassedTest
(ITestNGMethod tm, ITestResult tr) void
addSkippedTest
(ITestNGMethod tm, ITestResult tr) createWorkers
(List<ITestNGMethod> methods) Create a list of workers to run the methods passed in parameter.getAttribute
(String name) String[]
getHost()
String[]
getName()
getSuite()
getTest()
static int
removeAttribute
(String name) Remove the attributevoid
run()
The main entry method for TestRunner.void
setAttribute
(String name, Object value) Set a custom attribute.void
void
setTestName
(String name) void
setVerbose
(int n)
-
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, ISuiteRunnerListener suiteRunner) -
TestRunner
public TestRunner(IConfiguration configuration, ISuite suite, XmlTest test, boolean skipFailedInvocationCounts, Collection<IInvokedMethodListener> invokedMethodListeners, List<IClassListener> classListeners, Comparator<ITestNGMethod> comparator, ISuiteRunnerListener suiteRunner) -
TestRunner
public TestRunner(IConfiguration configuration, ISuite suite, XmlTest test, boolean skipFailedInvocationCounts, Collection<IInvokedMethodListener> invokedMethodListeners, List<IClassListener> classListeners, ISuiteRunnerListener suiteRunner)
-
-
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:
createWorkers
in interfaceIThreadWorkerFactory<ITestNGMethod>
- Parameters:
methods
- tasks that need to be executed- Returns:
- list of workers
-
getName
- Specified by:
getName
in interfaceITestContext
- Returns:
- The name of this test.
-
getStartDate
- Specified by:
getStartDate
in interfaceITestContext
- Returns:
- Returns the startDate.
-
getEndDate
- Specified by:
getEndDate
in interfaceITestContext
- Returns:
- Returns the endDate.
-
getPassedTests
- Specified by:
getPassedTests
in interfaceITestContext
- Returns:
- A list of all the tests that run successfully.
-
getSkippedTests
- Specified by:
getSkippedTests
in interfaceITestContext
- Returns:
- A list of all the tests that were skipped
-
getFailedTests
- Specified by:
getFailedTests
in interfaceITestContext
- Returns:
- A map of all the tests that failed, indexed by their ITestNGMethod.
- See Also:
-
getFailedButWithinSuccessPercentageTests
- Specified by:
getFailedButWithinSuccessPercentageTests
in interfaceITestContext
- Returns:
- A list of all the tests that failed but are being ignored because annotated with a successPercentage.
-
getIncludedGroups
- Specified by:
getIncludedGroups
in interfaceITestContext
- Returns:
- All the groups that are included for this test run.
-
getExcludedGroups
- Specified by:
getExcludedGroups
in interfaceITestContext
- Returns:
- All the groups that are excluded for this test run.
-
getOutputDirectory
- Specified by:
getOutputDirectory
in interfaceITestContext
- Returns:
- Where the reports will be generated.
-
getSuite
- Specified by:
getSuite
in interfaceITestContext
- Returns:
- Returns the suite.
-
getAllTestMethods
- Specified by:
getAllTestMethods
in interfaceITestContext
- Returns:
- All the test methods that were run.
-
getHost
- Specified by:
getHost
in 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:
getExcludedMethods
in interfaceITestContext
- Returns:
- All the methods that were not included in this test run.
-
getFailedConfigurations
- Specified by:
getFailedConfigurations
in interfaceITestContext
- Returns:
- The information about the failed configuration method invocations.
- See Also:
-
getConfigurationsScheduledForInvocation
- Specified by:
getConfigurationsScheduledForInvocation
in interfaceIConfigEavesdropper
-
getPassedConfigurations
- Specified by:
getPassedConfigurations
in interfaceITestContext
- Returns:
- The information about the successful configuration method invocations.
- See Also:
-
getSkippedConfigurations
- Specified by:
getSkippedConfigurations
in interfaceITestContext
- Returns:
- The information about the skipped configuration method invocations.
- See Also:
-
addPassedTest
- Specified by:
addPassedTest
in interfaceITestResultNotifier
-
getPassedTests
- Specified by:
getPassedTests
in interfaceITestResultNotifier
-
getFailedTests
- Specified by:
getFailedTests
in interfaceITestResultNotifier
-
getSkippedTests
- Specified by:
getSkippedTests
in interfaceITestResultNotifier
-
addSkippedTest
- Specified by:
addSkippedTest
in interfaceITestResultNotifier
-
addFailedTest
- Specified by:
addFailedTest
in interfaceITestResultNotifier
-
addFailedButWithinSuccessPercentageTest
- Specified by:
addFailedButWithinSuccessPercentageTest
in interfaceITestResultNotifier
-
getTest
- Specified by:
getTest
in interfaceITestResultNotifier
-
getTestListeners
- Specified by:
getTestListeners
in interfaceITestResultNotifier
-
getConfigurationListeners
- Specified by:
getConfigurationListeners
in interfaceITestResultNotifier
-
getVerbose
public static int getVerbose() -
setVerbose
public void setVerbose(int n) -
addListener
-
getExitCodeListener
- Specified by:
getExitCodeListener
in interfaceITestResultNotifier
-
getCurrentXmlTest
- Specified by:
getCurrentXmlTest
in interfaceITestContext
- Returns:
- the current XmlTest.
-
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
-
getInjectorFactory
- Specified by:
getInjectorFactory
in interfaceITestContext
-