com.beust.testng
Class TestRunner

java.lang.Object
  extended by com.beust.testng.TestRunner
All Implemented Interfaces:
ITestContext

public abstract class TestRunner
extends java.lang.Object
implements ITestContext

This class takes care of running one Test (one property file).

Author:
Cedric Beust, Apr 26, 2004, Alexandru Popescu

Field Summary
protected  XmlTest m_xmlTest
           
 
Constructor Summary
TestRunner(ISuite suite, XmlTest test)
           
TestRunner(ISuite suite, XmlTest test, java.lang.String outputDirectory)
           
 
Method Summary
 void addFailedButWithinSuccessPercentageTest(ITestNGMethod testMethod, ITestResult result)
           
 void addFailedTest(ITestNGMethod testMethod, ITestResult result)
           
 void addInvokedMethod(InvokedMethod im)
           
 void addPassedTest(ITestNGMethod tm, ITestResult tr)
           
 void addSkippedTest(ITestNGMethod tm, ITestResult tr)
           
 void addTestListener(ITestListener il)
           
 ITestNGMethod[] collectAndOrderTestMethods(ITestNGMethod[] methods)
           
 ITestNGMethod[] getAllTestMethods()
           
protected abstract  IAnnotationFinder getAnnotationFinder()
          Determines the annotation type to be further used.
 java.util.Date getEndDate()
          When this test stopped running.
 java.lang.String[] getExcludedGroups()
           
 java.util.Map getFailedButWithinSuccessPercentageTests()
           
 java.util.Map getFailedTests()
           
 java.lang.String[] getIncludedGroups()
           
 java.util.Collection<ITestNGMethod> getInvokedMethods()
           
 java.lang.String getName()
          The name of this test.
 java.lang.String getOutputDirectory()
           
 ITestResult getPassedTest(ITestNGMethod tm)
           
 java.util.Map<ITestNGMethod,ITestResult> getPassedTests()
           
 java.util.Map<ITestNGMethod,ITestResult> getSkippedTests()
           
 java.util.Date getStartDate()
          When this test started running.
 ISuite getSuite()
           
 XmlTest getTest()
           
 java.util.List<ITestListener> getTestListeners()
           
 ITestNGMethod[] getTestMethods()
           
static int getVerbose()
           
 void privateRun()
           
 void run()
          The main entry method for TestRunner.
 void setOutputDirectory(java.lang.String od)
           
 void setTestName(java.lang.String name)
           
 void setVerbose(int n)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_xmlTest

protected XmlTest m_xmlTest
Constructor Detail

TestRunner

public TestRunner(ISuite suite,
                  XmlTest test,
                  java.lang.String outputDirectory)

TestRunner

public TestRunner(ISuite suite,
                  XmlTest test)
Method Detail

getAnnotationFinder

protected abstract IAnnotationFinder getAnnotationFinder()
Determines the annotation type to be further used. Must be implemented by subclasses.


getName

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

Specified by:
getName in interface ITestContext

getIncludedGroups

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

getExcludedGroups

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

setTestName

public void setTestName(java.lang.String name)

setOutputDirectory

public void setOutputDirectory(java.lang.String od)

getOutputDirectory

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

getEndDate

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

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

getStartDate

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

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

collectAndOrderTestMethods

public ITestNGMethod[] collectAndOrderTestMethods(ITestNGMethod[] methods)
Parameters:
methods -
Returns:
All the methods that match the filtered groups. If a method belongs to an excluded group, it is automatically excluded.

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...


privateRun

public void privateRun()
                throws java.lang.InstantiationException,
                       java.lang.IllegalAccessException
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException

addPassedTest

public void addPassedTest(ITestNGMethod tm,
                          ITestResult tr)

getPassedTest

public ITestResult getPassedTest(ITestNGMethod tm)

addSkippedTest

public void addSkippedTest(ITestNGMethod tm,
                           ITestResult tr)

addInvokedMethod

public void addInvokedMethod(InvokedMethod im)

addFailedTest

public void addFailedTest(ITestNGMethod testMethod,
                          ITestResult result)

addFailedButWithinSuccessPercentageTest

public void addFailedButWithinSuccessPercentageTest(ITestNGMethod testMethod,
                                                    ITestResult result)

getTest

public XmlTest getTest()

getTestListeners

public java.util.List<ITestListener> getTestListeners()

getTestMethods

public ITestNGMethod[] getTestMethods()

getVerbose

public static int getVerbose()

setVerbose

public void setVerbose(int n)

getPassedTests

public java.util.Map<ITestNGMethod,ITestResult> getPassedTests()
Specified by:
getPassedTests in interface ITestContext
Returns:
A list of all the tests that run successfully.

getSkippedTests

public java.util.Map<ITestNGMethod,ITestResult> getSkippedTests()
Specified by:
getSkippedTests in interface ITestContext
Returns:
A list of all the tests that were skipped

getFailedTests

public java.util.Map 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 java.util.Map 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.

addTestListener

public void addTestListener(ITestListener il)

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.

getInvokedMethods

public java.util.Collection<ITestNGMethod> getInvokedMethods()
Returns: