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 ITestResultNotifier
private Map<junit.framework.Test,
JUnitTestRunner.TestRunInfo> static final String
Fields inherited from interface org.testng.junit.IJUnitTestRunner
JUNIT_4_TESTRUNNER, JUNIT_TESTRUNNER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addFailure
(junit.framework.Test test, junit.framework.AssertionFailedError t) protected junit.framework.TestResult
Creates the TestResult to be used for the test run.protected junit.framework.TestResult
doRun
(junit.framework.Test suite) void
endTest
(junit.framework.Test test) protected junit.framework.Test
Returns the Test corresponding to the given suite.Needed from TestRunner in order to figure out what JUnit test methods were run.private void
recordFailure
(junit.framework.Test test, Throwable t) private TestResult
recordResults
(junit.framework.Test test, JUnitTestRunner.TestRunInfo tri) void
Astart
implementation that ignores theTestResult
protected void
void
void
setTestResultNotifier
(ITestResultNotifier notifier) junit.framework.TestResult
Starts a test run.void
startTest
(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:
getTestMethods
in interfaceIJUnitTestRunner
- Returns:
- the list of all JUnit test methods run
-
setTestResultNotifier
- Specified by:
setTestResultNotifier
in interfaceIJUnitTestRunner
-
startTest
public void startTest(junit.framework.Test test) - Specified by:
startTest
in interfacejunit.framework.TestListener
- See Also:
-
TestListener.startTest(junit.framework.Test)
-
addError
- Specified by:
addError
in 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:
addFailure
in interfacejunit.framework.TestListener
- See Also:
-
TestListener.addFailure(junit.framework.Test, junit.framework.AssertionFailedError)
-
recordFailure
-
endTest
public void endTest(junit.framework.Test test) - Specified by:
endTest
in interfacejunit.framework.TestListener
- See Also:
-
TestListener.endTest(junit.framework.Test)
-
setInvokedMethodListeners
- Specified by:
setInvokedMethodListeners
in 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
Astart
implementation that ignores theTestResult
- Specified by:
run
in 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)
-