Package org.testng.junit
Class JUnitTestRunner
java.lang.Object
org.testng.junit.JUnitTestRunner
- All Implemented Interfaces:
junit.framework.TestListener,IJUnitTestRunner
public class JUnitTestRunner
extends Object
implements junit.framework.TestListener, IJUnitTestRunner
A JUnit TestRunner that records/triggers all information/events necessary to TestNG.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Collection<IInvokedMethodListener>private List<ITestNGMethod>private ITestResultNotifierprivate Map<junit.framework.Test,JUnitTestRunner.TestRunInfo> static final StringFields inherited from interface org.testng.junit.IJUnitTestRunner
JUNIT_4_TESTRUNNER, JUNIT_TESTRUNNER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddFailure(junit.framework.Test test, junit.framework.AssertionFailedError t) protected junit.framework.TestResultCreates 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.TestReturns the Test corresponding to the given suite.Needed from TestRunner in order to figure out what JUnit test methods were run.private voidrecordFailure(junit.framework.Test test, Throwable t) private TestResultrecordResults(junit.framework.Test test, JUnitTestRunner.TestRunInfo tri) voidAstartimplementation that ignores theTestResultprotected voidvoidvoidsetTestResultNotifier(ITestResultNotifier notifier) junit.framework.TestResultStarts a test run.voidstartTest(junit.framework.Test test)
-
Field Details
-
SUITE_METHODNAME
- See Also:
-
m_parentRunner
-
m_tests
-
m_methods
-
m_invokedMethodListeners
-
-
Constructor Details
-
JUnitTestRunner
public JUnitTestRunner() -
JUnitTestRunner
-
-
Method Details
-
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
- 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
- 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)
-
recordFailure
-
endTest
public void endTest(junit.framework.Test test) - Specified by:
endTestin interfacejunit.framework.TestListener- See Also:
-
TestListener.endTest(junit.framework.Test)
-
setInvokedMethodListeners
- Specified by:
setInvokedMethodListenersin interfaceIJUnitTestRunner
-
recordResults
-
getTest
Returns the Test corresponding to the given suite. This is a template method, subclasses override runFailed(), clearStatus().- Parameters:
testClass- The test classmethods- The test methods- Returns:
- The corresponding Test
-
run
Astartimplementation that ignores theTestResult- Specified by:
runin interfaceIJUnitTestRunner- Parameters:
testClass- the JUnit test class
-
start
Starts a test run. Analyzes the command line arguments and runs the given test suite.- Parameters:
testCase- The test class to runmethods- The test methods to run- Returns:
- The test result
-
runFailed
-
createTestResult
protected junit.framework.TestResult createTestResult()Creates the TestResult to be used for the test run.- Returns:
- The created test result
-
doRun
protected junit.framework.TestResult doRun(junit.framework.Test suite)
-