Package org.testng.junit
Class JUnitTestRunner
- java.lang.Object
-
- org.testng.junit.JUnitTestRunner
-
- All Implemented Interfaces:
junit.framework.TestListener,IJUnitTestRunner
public class JUnitTestRunner extends java.lang.Object implements junit.framework.TestListener, IJUnitTestRunner
A JUnit TestRunner that records/triggers all information/events necessary to TestNG.- Author:
- Alexandru Popescu
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSUITE_METHODNAME
-
Constructor Summary
Constructors Constructor Description JUnitTestRunner()JUnitTestRunner(ITestResultNotifier tr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddError(junit.framework.Test test, java.lang.Throwable t)voidaddFailure(junit.framework.Test test, junit.framework.AssertionFailedError t)protected junit.framework.TestResultcreateTestResult()Creates the TestResult to be used for the test run.protected junit.framework.TestResultdoRun(junit.framework.Test suite)voidendTest(junit.framework.Test test)protected junit.framework.TestgetTest(java.lang.Class testClass, java.lang.String... methods)Returns the Test corresponding to the given suite.java.util.List<ITestNGMethod>getTestMethods()Needed from TestRunner in order to figure out what JUnit test methods were run.voidrun(java.lang.Class testClass, java.lang.String... methods)Astartimplementation that ignores theTestResultprotected voidrunFailed(java.lang.Class clazz, java.lang.String message)voidsetInvokedMethodListeners(java.util.Collection<IInvokedMethodListener> listeners)voidsetTestResultNotifier(ITestResultNotifier notifier)junit.framework.TestResultstart(java.lang.Class testCase, java.lang.String... methods)Starts a test run.voidstartTest(junit.framework.Test test)
-
-
-
Field Detail
-
SUITE_METHODNAME
public static final java.lang.String SUITE_METHODNAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JUnitTestRunner
public JUnitTestRunner()
-
JUnitTestRunner
public JUnitTestRunner(ITestResultNotifier tr)
-
-
Method Detail
-
getTestMethods
public java.util.List<ITestNGMethod> getTestMethods()
Needed from TestRunner in order to figure out what JUnit test methods were run.- Specified by:
getTestMethodsin interfaceIJUnitTestRunner- Returns:
- the list of all JUnit test methods run
-
setTestResultNotifier
public void setTestResultNotifier(ITestResultNotifier notifier)
- Specified by:
setTestResultNotifierin interfaceIJUnitTestRunner
-
startTest
public void startTest(junit.framework.Test test)
- Specified by:
startTestin interfacejunit.framework.TestListener- See Also:
TestListener.startTest(junit.framework.Test)
-
addError
public void addError(junit.framework.Test test, java.lang.Throwable t)- Specified by:
addErrorin interfacejunit.framework.TestListener- See Also:
TestListener.addError(junit.framework.Test, java.lang.Throwable)
-
addFailure
public void addFailure(junit.framework.Test test, junit.framework.AssertionFailedError t)- Specified by:
addFailurein interfacejunit.framework.TestListener- See Also:
TestListener.addFailure(junit.framework.Test, junit.framework.AssertionFailedError)
-
endTest
public void endTest(junit.framework.Test test)
- Specified by:
endTestin interfacejunit.framework.TestListener- See Also:
TestListener.endTest(junit.framework.Test)
-
setInvokedMethodListeners
public void setInvokedMethodListeners(java.util.Collection<IInvokedMethodListener> listeners)
- Specified by:
setInvokedMethodListenersin interfaceIJUnitTestRunner
-
getTest
protected junit.framework.Test getTest(java.lang.Class testClass, java.lang.String... methods)Returns the Test corresponding to the given suite. This is a template method, subclasses override runFailed(), clearStatus().
-
run
public void run(java.lang.Class testClass, java.lang.String... methods)Astartimplementation that ignores theTestResult- Specified by:
runin interfaceIJUnitTestRunner- Parameters:
testClass- the JUnit test class
-
start
public junit.framework.TestResult start(java.lang.Class testCase, java.lang.String... methods)Starts a test run. Analyzes the command line arguments and runs the given test suite.
-
runFailed
protected void runFailed(java.lang.Class clazz, java.lang.String message)
-
createTestResult
protected junit.framework.TestResult createTestResult()
Creates the TestResult to be used for the test run.
-
doRun
protected junit.framework.TestResult doRun(junit.framework.Test suite)
-
-