org.testng
Class TestRunner

java.lang.Object  extended by org.testng.TestRunner
All Implemented Interfaces:
Serializable, IAttributes, org.testng.internal.ITestResultNotifier, org.testng.internal.thread.graph.IThreadWorkerFactory<ITestNGMethod>, ITestContext

public class TestRunner
extends Object
implements ITestContext, org.testng.internal.ITestResultNotifier, org.testng.internal.thread.graph.IThreadWorkerFactory<ITestNGMethod>

This class takes care of running one Test.

Author:
Cedric Beust, Apr 26, 2004
See Also:
Serialized Form


Constructor Summary
 TestRunner(org.testng.internal.IConfiguration configuration, ISuite suite, XmlTest test, boolean skipFailedInvocationCounts, List<IInvokedMethodListener> listeners)
           
protected TestRunner(org.testng.internal.IConfiguration configuration, ISuite suite, XmlTest test, String outputDirectory, org.testng.internal.annotations.IAnnotationFinder finder, boolean skipFailedInvocationCounts, List<IInvokedMethodListener> invokedMethodListeners)
           
 
Method Summary
 voidaddFailedButWithinSuccessPercentageTest(ITestNGMethod testMethod, ITestResult result)
           
 voidaddFailedTest(ITestNGMethod testMethod, ITestResult result)
           
 voidaddGuiceModule(Class<? extends com.google.inject.Module> cls, com.google.inject.Module module)
           
 voidaddInjector(List<com.google.inject.Module> moduleInstances, com.google.inject.Injector injector)
           
 voidaddInvokedMethod(org.testng.internal.InvokedMethod im)
           
 voidaddListener(Object listener)
           
 voidaddPassedTest(ITestNGMethod tm, ITestResult tr)
           
 voidaddSkippedTest(ITestNGMethod tm, ITestResult tr)
           
 voidaddTestListener(ITestListener il)
           
 List<org.testng.internal.thread.graph.IWorker<ITestNGMethod>>createWorkers(List<ITestNGMethod> methods)
          Create a list of workers to run the methods passed in parameter.
 ITestNGMethod[]getAfterSuiteMethods()
           
 ITestNGMethod[]getAfterTestConfigurationMethods()
           
 ITestNGMethod[]getAllTestMethods()
           
 ObjectgetAttribute(String name)
           
 Set<String>getAttributeNames()
           
 ITestNGMethod[]getBeforeSuiteMethods()
           
 ITestNGMethod[]getBeforeTestConfigurationMethods()
           
 List<IConfigurationListener>getConfigurationListeners()
           
 XmlTestgetCurrentXmlTest()
           
 DategetEndDate()
          When this test stopped running.
 String[]getExcludedGroups()
           
 Collection<ITestNGMethod>getExcludedMethods()
           
 IResultMapgetFailedButWithinSuccessPercentageTests()
           
 IResultMapgetFailedConfigurations()
          Retrieves information about the failed configuration method invocations.
 IResultMapgetFailedTests()
           
 Set<ITestResult>getFailedTests(ITestNGMethod tm)
           
 List<com.google.inject.Module>getGuiceModules(Class<? extends com.google.inject.Module> cls)
           
 StringgetHost()
           
 String[]getIncludedGroups()
           
 com.google.inject.InjectorgetInjector(List<com.google.inject.Module> moduleInstances)
           
 List<ITestNGMethod>getInvokedMethods()
           
 org.testng.internal.IInvokergetInvoker()
           
 StringgetName()
          The name of this test.
 StringgetOutputDirectory()
           
 IResultMapgetPassedConfigurations()
          Retrieves information about the successful configuration method invocations.
 IResultMapgetPassedTests()
           
 Set<ITestResult>getPassedTests(ITestNGMethod tm)
           
 IResultMapgetSkippedConfigurations()
          Retrieves information about the skipped configuration method invocations.
 IResultMapgetSkippedTests()
           
 Set<ITestResult>getSkippedTests(ITestNGMethod tm)
           
 DategetStartDate()
          When this test started running.
 ISuitegetSuite()
           
 XmlTestgetTest()
           
 Collection<ITestClass>getTestClasses()
           
 List<ITestListener>getTestListeners()
           
static intgetVerbose()
           
 ObjectremoveAttribute(String name)
          Remove the attribute
 voidrun()
          The main entry method for TestRunner.
 voidsetAttribute(String name, Object value)
          Set a custom attribute.
 voidsetMethodInterceptor(IMethodInterceptor methodInterceptor)
           
 voidsetOutputDirectory(String od)
           
 voidsetTestName(String name)
           
 voidsetVerbose(int n)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestRunner

protected TestRunner(org.testng.internal.IConfiguration configuration,                     ISuite suite,                     XmlTest test,                     String outputDirectory,                     org.testng.internal.annotations.IAnnotationFinder finder,                     boolean skipFailedInvocationCounts,                     List<IInvokedMethodListener> invokedMethodListeners)

TestRunner

public TestRunner(org.testng.internal.IConfiguration configuration,                  ISuite suite,                  XmlTest test,                  boolean skipFailedInvocationCounts,                  List<IInvokedMethodListener> listeners)
Method Detail

getInvoker

public org.testng.internal.IInvoker getInvoker()

getBeforeSuiteMethods

public ITestNGMethod[] getBeforeSuiteMethods()

getAfterSuiteMethods

public ITestNGMethod[] getAfterSuiteMethods()

getBeforeTestConfigurationMethods

public ITestNGMethod[] getBeforeTestConfigurationMethods()

getAfterTestConfigurationMethods

public ITestNGMethod[] getAfterTestConfigurationMethods()

getTestClasses

public Collection<ITestClass> getTestClasses()

setTestName

public void setTestName(String name)

setOutputDirectory

public void setOutputDirectory(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 List<org.testng.internal.thread.graph.IWorker<ITestNGMethod>> createWorkers(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:
createWorkers in interface org.testng.internal.thread.graph.IThreadWorkerFactory<ITestNGMethod>

getName

public String getName()
Description copied from interface: ITestContext
The name of this test.

Specified by:
getName in interface ITestContext

getStartDate

public Date getStartDate()
Description copied from interface: ITestContext
When this test started running.

Specified by:
getStartDate in interface ITestContext
Returns:
Returns the startDate.

getEndDate

public Date getEndDate()
Description copied from interface: ITestContext
When this test stopped running.

Specified by:
getEndDate in interface ITestContext
Returns:
Returns the endDate.

getPassedTests

public IResultMap getPassedTests()
Specified by:
getPassedTests in interface ITestContext
Returns:
A list of all the tests that run successfully.

getSkippedTests

public IResultMap getSkippedTests()
Specified by:
getSkippedTests in interface ITestContext
Returns:
A list of all the tests that were skipped

getFailedTests

public IResultMap getFailedTests()
Specified by:
getFailedTests in interface ITestContext
Returns:
A map of all the tests that passed, indexed by their ITextMethor.
See Also:
ITestNGMethod

getFailedButWithinSuccessPercentageTests

public IResultMap getFailedButWithinSuccessPercentageTests()
Specified by:
getFailedButWithinSuccessPercentageTests in interface ITestContext
Returns:
A list of all the tests that failed but are being ignored because annotated with a successPercentage.

getIncludedGroups

public String[] getIncludedGroups()
Specified by:
getIncludedGroups in interface ITestContext
Returns:
All the groups that are included for this test run.

getExcludedGroups

public String[] getExcludedGroups()
Specified by:
getExcludedGroups in interface ITestContext
Returns:
All the groups that are excluded for this test run.

getOutputDirectory

public String getOutputDirectory()
Specified by:
getOutputDirectory in interface ITestContext
Returns:
Where the reports will be generated.

getSuite

public ISuite getSuite()
Specified by:
getSuite in interface ITestContext
Returns:
Returns the suite.

getAllTestMethods

public ITestNGMethod[] getAllTestMethods()
Specified by:
getAllTestMethods in interface ITestContext
Returns:
All the test methods that were run.

getHost

public String getHost()
Specified by:
getHost in interface ITestContext
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 Collection<ITestNGMethod> getExcludedMethods()
Specified by:
getExcludedMethods in interface ITestContext
Returns:
All the methods that were not included in this test run.

getFailedConfigurations

public IResultMap getFailedConfigurations()
Description copied from interface: ITestContext
Retrieves information about the failed configuration method invocations.

Specified by:
getFailedConfigurations in interface ITestContext
See Also:
ITestContext.getFailedConfigurations()

getPassedConfigurations

public IResultMap getPassedConfigurations()
Description copied from interface: ITestContext
Retrieves information about the successful configuration method invocations.

Specified by:
getPassedConfigurations in interface ITestContext
See Also:
ITestContext.getPassedConfigurations()

getSkippedConfigurations

public IResultMap getSkippedConfigurations()
Description copied from interface: ITestContext
Retrieves information about the skipped configuration method invocations.

Specified by:
getSkippedConfigurations in interface ITestContext
See Also:
ITestContext.getSkippedConfigurations()

addPassedTest

public void addPassedTest(ITestNGMethod tm,                          ITestResult tr)
Specified by:
addPassedTest in interface org.testng.internal.ITestResultNotifier

getPassedTests

public Set<ITestResult> getPassedTests(ITestNGMethod tm)
Specified by:
getPassedTests in interface org.testng.internal.ITestResultNotifier

getFailedTests

public Set<ITestResult> getFailedTests(ITestNGMethod tm)
Specified by:
getFailedTests in interface org.testng.internal.ITestResultNotifier

getSkippedTests

public Set<ITestResult> getSkippedTests(ITestNGMethod tm)
Specified by:
getSkippedTests in interface org.testng.internal.ITestResultNotifier

addSkippedTest

public void addSkippedTest(ITestNGMethod tm,                           ITestResult tr)
Specified by:
addSkippedTest in interface org.testng.internal.ITestResultNotifier

addInvokedMethod

public void addInvokedMethod(org.testng.internal.InvokedMethod im)
Specified by:
addInvokedMethod in interface org.testng.internal.ITestResultNotifier

addFailedTest

public void addFailedTest(ITestNGMethod testMethod,                          ITestResult result)
Specified by:
addFailedTest in interface org.testng.internal.ITestResultNotifier

addFailedButWithinSuccessPercentageTest

public void addFailedButWithinSuccessPercentageTest(ITestNGMethod testMethod,                                                    ITestResult result)
Specified by:
addFailedButWithinSuccessPercentageTest in interface org.testng.internal.ITestResultNotifier

getTest

public XmlTest getTest()
Specified by:
getTest in interface org.testng.internal.ITestResultNotifier

getTestListeners

public List<ITestListener> getTestListeners()
Specified by:
getTestListeners in interface org.testng.internal.ITestResultNotifier

getConfigurationListeners

public List<IConfigurationListener> getConfigurationListeners()
Specified by:
getConfigurationListeners in interface org.testng.internal.ITestResultNotifier

getVerbose

public static int getVerbose()

setVerbose

public void setVerbose(int n)

addListener

public void addListener(Object listener)

addTestListener

public void addTestListener(ITestListener il)

getInvokedMethods

public List<ITestNGMethod> getInvokedMethods()

setMethodInterceptor

public void setMethodInterceptor(IMethodInterceptor methodInterceptor)

getCurrentXmlTest

public XmlTest getCurrentXmlTest()
Specified by:
getCurrentXmlTest in interface ITestContext
Returns:
the current XmlTest.

getAttribute

public Object getAttribute(String name)
Specified by:
getAttribute in interface IAttributes
Parameters:
name - The name of the attribute to return

setAttribute

public void setAttribute(String name,                         Object value)
Description copied from interface: IAttributes
Set a custom attribute.

Specified by:
setAttribute in interface IAttributes

getAttributeNames

public Set<String> getAttributeNames()
Specified by:
getAttributeNames in interface IAttributes
Returns:
all the attributes names.

removeAttribute

public Object removeAttribute(String name)
Description copied from interface: IAttributes
Remove the attribute

Specified by:
removeAttribute in interface IAttributes
Returns:
the attribute value if found, null otherwise

getGuiceModules

public List<com.google.inject.Module> getGuiceModules(Class<? extends com.google.inject.Module> cls)
Specified by:
getGuiceModules in interface ITestContext

addGuiceModule

public void addGuiceModule(Class<? extends com.google.inject.Module> cls,                           com.google.inject.Module module)
Specified by:
addGuiceModule in interface ITestContext

getInjector

public com.google.inject.Injector getInjector(List<com.google.inject.Module> moduleInstances)
Specified by:
getInjector in interface ITestContext

addInjector

public void addInjector(List<com.google.inject.Module> moduleInstances,                        com.google.inject.Injector injector)
Specified by:
addInjector in interface ITestContext


Copyright © 2012. All Rights Reserved.


NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14