Package org.testng
Class TestRunner
- java.lang.Object
-
- org.testng.TestRunner
-
- All Implemented Interfaces:
IAttributes,ITestResultNotifier,IThreadWorkerFactory<ITestNGMethod>,ITestContext
public class TestRunner extends java.lang.Object implements ITestContext, ITestResultNotifier, IThreadWorkerFactory<ITestNGMethod>
This class takes care of running one Test.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTestRunner.PriorityWeight
-
Constructor Summary
Constructors Modifier Constructor 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)protectedTestRunner(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)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFailedButWithinSuccessPercentageTest(ITestNGMethod testMethod, ITestResult result)voidaddFailedTest(ITestNGMethod testMethod, ITestResult result)voidaddInjector(java.util.List<com.google.inject.Module> moduleInstances, com.google.inject.Injector injector)voidaddInvokedMethod(InvokedMethod im)voidaddListener(ITestNGListener listener)voidaddPassedTest(ITestNGMethod tm, ITestResult tr)voidaddSkippedTest(ITestNGMethod tm, ITestResult tr)java.util.List<IWorker<ITestNGMethod>>createWorkers(java.util.List<ITestNGMethod> methods)Create a list of workers to run the methods passed in parameter.ITestNGMethod[]getAfterSuiteMethods()ITestNGMethod[]getAfterTestConfigurationMethods()ITestNGMethod[]getAllTestMethods()java.lang.ObjectgetAttribute(java.lang.String name)java.util.Set<java.lang.String>getAttributeNames()ITestNGMethod[]getBeforeSuiteMethods()ITestNGMethod[]getBeforeTestConfigurationMethods()java.util.List<IConfigurationListener>getConfigurationListeners()XmlTestgetCurrentXmlTest()java.util.DategetEndDate()When this test stopped running.java.lang.String[]getExcludedGroups()java.util.Collection<ITestNGMethod>getExcludedMethods()IResultMapgetFailedButWithinSuccessPercentageTests()IResultMapgetFailedConfigurations()Retrieves information about the failed configuration method invocations.IResultMapgetFailedTests()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.StringgetHost()java.lang.String[]getIncludedGroups()com.google.inject.InjectorgetInjector(java.util.List<com.google.inject.Module> moduleInstances)com.google.inject.InjectorgetInjector(IClass iClass)java.util.List<ITestNGMethod>getInvokedMethods()IInvokergetInvoker()java.lang.StringgetName()The name of this test.java.lang.StringgetOutputDirectory()IResultMapgetPassedConfigurations()Retrieves information about the successful configuration method invocations.IResultMapgetPassedTests()java.util.Set<ITestResult>getPassedTests(ITestNGMethod tm)IResultMapgetSkippedConfigurations()Retrieves information about the skipped configuration method invocations.IResultMapgetSkippedTests()java.util.Set<ITestResult>getSkippedTests(ITestNGMethod tm)java.util.DategetStartDate()When this test started running.ISuitegetSuite()XmlTestgetTest()java.util.Collection<ITestClass>getTestClasses()java.util.List<ITestListener>getTestListeners()static intgetVerbose()java.lang.ObjectremoveAttribute(java.lang.String name)Remove the attributevoidrun()The main entry method for TestRunner.voidsetAttribute(java.lang.String name, java.lang.Object value)Set a custom attribute.voidsetOutputDirectory(java.lang.String od)voidsetTestName(java.lang.String name)voidsetVerbose(int n)
-
-
-
Constructor Detail
-
TestRunner
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)
-
TestRunner
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)
-
TestRunner
public 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.
-
-
Method Detail
-
getInvoker
public IInvoker getInvoker()
-
getBeforeSuiteMethods
public ITestNGMethod[] getBeforeSuiteMethods()
-
getAfterSuiteMethods
public ITestNGMethod[] getAfterSuiteMethods()
-
getBeforeTestConfigurationMethods
public ITestNGMethod[] getBeforeTestConfigurationMethods()
-
getAfterTestConfigurationMethods
public ITestNGMethod[] getAfterTestConfigurationMethods()
-
getTestClasses
public java.util.Collection<ITestClass> getTestClasses()
-
setTestName
public void setTestName(java.lang.String name)
-
setOutputDirectory
public void setOutputDirectory(java.lang.String od)
-
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
public java.util.List<IWorker<ITestNGMethod>> createWorkers(java.util.List<ITestNGMethod> methods)
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
public java.lang.String getName()
Description copied from interface:ITestContextThe name of this test.- Specified by:
getNamein interfaceITestContext
-
getStartDate
public java.util.Date getStartDate()
Description copied from interface:ITestContextWhen this test started running.- Specified by:
getStartDatein interfaceITestContext- Returns:
- Returns the startDate.
-
getEndDate
public java.util.Date getEndDate()
Description copied from interface:ITestContextWhen this test stopped running.- Specified by:
getEndDatein interfaceITestContext- Returns:
- Returns the endDate.
-
getPassedTests
public IResultMap getPassedTests()
- Specified by:
getPassedTestsin interfaceITestContext- Returns:
- A list of all the tests that run successfully.
-
getSkippedTests
public IResultMap getSkippedTests()
- Specified by:
getSkippedTestsin interfaceITestContext- Returns:
- A list of all the tests that were skipped
-
getFailedTests
public IResultMap getFailedTests()
- Specified by:
getFailedTestsin interfaceITestContext- Returns:
- A map of all the tests that passed, indexed by their ITextMethor.
- See Also:
ITestNGMethod
-
getFailedButWithinSuccessPercentageTests
public IResultMap getFailedButWithinSuccessPercentageTests()
- Specified by:
getFailedButWithinSuccessPercentageTestsin interfaceITestContext- Returns:
- A list of all the tests that failed but are being ignored because annotated with a successPercentage.
-
getIncludedGroups
public java.lang.String[] getIncludedGroups()
- Specified by:
getIncludedGroupsin interfaceITestContext- Returns:
- All the groups that are included for this test run.
-
getExcludedGroups
public java.lang.String[] getExcludedGroups()
- Specified by:
getExcludedGroupsin interfaceITestContext- Returns:
- All the groups that are excluded for this test run.
-
getOutputDirectory
public java.lang.String getOutputDirectory()
- Specified by:
getOutputDirectoryin interfaceITestContext- Returns:
- Where the reports will be generated.
-
getSuite
public ISuite getSuite()
- Specified by:
getSuitein interfaceITestContext- Returns:
- Returns the suite.
-
getAllTestMethods
public ITestNGMethod[] getAllTestMethods()
- Specified by:
getAllTestMethodsin interfaceITestContext- Returns:
- All the test methods that were run.
-
getHost
public java.lang.String 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
public java.util.Collection<ITestNGMethod> getExcludedMethods()
- Specified by:
getExcludedMethodsin interfaceITestContext- Returns:
- All the methods that were not included in this test run.
-
getFailedConfigurations
public IResultMap getFailedConfigurations()
Description copied from interface:ITestContextRetrieves information about the failed configuration method invocations.- Specified by:
getFailedConfigurationsin interfaceITestContext- See Also:
ITestContext.getFailedConfigurations()
-
getPassedConfigurations
public IResultMap getPassedConfigurations()
Description copied from interface:ITestContextRetrieves information about the successful configuration method invocations.- Specified by:
getPassedConfigurationsin interfaceITestContext- See Also:
ITestContext.getPassedConfigurations()
-
getSkippedConfigurations
public IResultMap getSkippedConfigurations()
Description copied from interface:ITestContextRetrieves information about the skipped configuration method invocations.- Specified by:
getSkippedConfigurationsin interfaceITestContext- See Also:
ITestContext.getSkippedConfigurations()
-
addPassedTest
public void addPassedTest(ITestNGMethod tm, ITestResult tr)
- Specified by:
addPassedTestin interfaceITestResultNotifier
-
getPassedTests
public java.util.Set<ITestResult> getPassedTests(ITestNGMethod tm)
- Specified by:
getPassedTestsin interfaceITestResultNotifier
-
getFailedTests
public java.util.Set<ITestResult> getFailedTests(ITestNGMethod tm)
- Specified by:
getFailedTestsin interfaceITestResultNotifier
-
getSkippedTests
public java.util.Set<ITestResult> getSkippedTests(ITestNGMethod tm)
- Specified by:
getSkippedTestsin interfaceITestResultNotifier
-
addSkippedTest
public void addSkippedTest(ITestNGMethod tm, ITestResult tr)
- Specified by:
addSkippedTestin interfaceITestResultNotifier
-
addInvokedMethod
public void addInvokedMethod(InvokedMethod im)
- Specified by:
addInvokedMethodin interfaceITestResultNotifier
-
addFailedTest
public void addFailedTest(ITestNGMethod testMethod, ITestResult result)
- Specified by:
addFailedTestin interfaceITestResultNotifier
-
addFailedButWithinSuccessPercentageTest
public void addFailedButWithinSuccessPercentageTest(ITestNGMethod testMethod, ITestResult result)
- Specified by:
addFailedButWithinSuccessPercentageTestin interfaceITestResultNotifier
-
getTest
public XmlTest getTest()
- Specified by:
getTestin interfaceITestResultNotifier
-
getTestListeners
public java.util.List<ITestListener> getTestListeners()
- Specified by:
getTestListenersin interfaceITestResultNotifier
-
getConfigurationListeners
public java.util.List<IConfigurationListener> getConfigurationListeners()
- Specified by:
getConfigurationListenersin interfaceITestResultNotifier
-
getVerbose
public static int getVerbose()
-
setVerbose
public void setVerbose(int n)
-
addListener
public void addListener(ITestNGListener listener)
-
getInvokedMethods
public java.util.List<ITestNGMethod> getInvokedMethods()
-
getCurrentXmlTest
public XmlTest getCurrentXmlTest()
- Specified by:
getCurrentXmlTestin interfaceITestContext- Returns:
- the current XmlTest.
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
- Specified by:
getAttributein interfaceIAttributes- Parameters:
name- The name of the attribute to return
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)Description copied from interface:IAttributesSet a custom attribute.- Specified by:
setAttributein interfaceIAttributes
-
getAttributeNames
public java.util.Set<java.lang.String> getAttributeNames()
- Specified by:
getAttributeNamesin interfaceIAttributes- Returns:
- all the attributes names.
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name)
Description copied from interface:IAttributesRemove the attribute- Specified by:
removeAttributein interfaceIAttributes- Returns:
- the attribute value if found, null otherwise
-
getGuiceModules
public java.util.List<com.google.inject.Module> getGuiceModules(java.lang.Class<? extends com.google.inject.Module> cls)
- Specified by:
getGuiceModulesin interfaceITestContext
-
getInjector
public com.google.inject.Injector getInjector(java.util.List<com.google.inject.Module> moduleInstances)
- Specified by:
getInjectorin interfaceITestContext
-
getInjector
public com.google.inject.Injector getInjector(IClass iClass)
- Specified by:
getInjectorin interfaceITestContext
-
addInjector
public void addInjector(java.util.List<com.google.inject.Module> moduleInstances, com.google.inject.Injector injector)- Specified by:
addInjectorin interfaceITestContext
-
-