Package junit.textui
Class TestRunner
java.lang.Object
junit.runner.BaseTestRunner
junit.textui.TestRunner
- All Implemented Interfaces:
TestListener
A command line based tool to run tests.
java junit.textui.TestRunner [-wait] TestCaseClass
TestRunner expects the name of a TestCase class as argument.
If this class defines a static suite
method it
will be invoked and the returned test is run. Otherwise all
the methods starting with "test" having no arguments are run.
When the wait command line argument is given TestRunner waits until the users types RETURN.
TestRunner prints a trace as the tests are executed followed by a summary at the end.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
private ResultPrinter
static final int
Fields inherited from class junit.runner.BaseTestRunner
SUITE_METHODNAME
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a TestRunner.TestRunner
(PrintStream writer) Constructs a TestRunner using the given stream for all the outputTestRunner
(ResultPrinter printer) Constructs a TestRunner using the given ResultPrinter all the output -
Method Summary
Modifier and TypeMethodDescriptionprotected TestResult
Creates the TestResult to be used for the test run.static void
protected void
pause
(boolean wait) static void
Runs a suite extracted from a TestCase subclass.static TestResult
Runs a single test and collects its results.static void
runAndWait
(Test suite) Runs a single test and waits until the user types RETURN.protected void
Override to define how to handle a failed loading of a test suite.protected TestResult
runSingleMethod
(String testCase, String method, boolean wait) void
setPrinter
(ResultPrinter printer) Starts a test run.void
void
testFailed
(int status, Test test, Throwable e) void
testStarted
(String testName) Methods inherited from class junit.runner.BaseTestRunner
addError, addFailure, clearStatus, elapsedTimeAsString, endTest, extractClassName, getFilteredTrace, getFilteredTrace, getPreference, getPreference, getPreferences, getTest, loadSuiteClass, processArguments, savePreferences, setLoading, setPreference, setPreferences, showStackRaw, startTest, truncate, useReloadingTestSuiteLoader
-
Field Details
-
fPrinter
-
SUCCESS_EXIT
public static final int SUCCESS_EXIT- See Also:
-
FAILURE_EXIT
public static final int FAILURE_EXIT- See Also:
-
EXCEPTION_EXIT
public static final int EXCEPTION_EXIT- See Also:
-
-
Constructor Details
-
TestRunner
public TestRunner()Constructs a TestRunner. -
TestRunner
Constructs a TestRunner using the given stream for all the output -
TestRunner
Constructs a TestRunner using the given ResultPrinter all the output
-
-
Method Details
-
run
Runs a suite extracted from a TestCase subclass. -
run
Runs a single test and collects its results. This method can be used to start a test run from your program.public static void main (String[] args) { test.textui.TestRunner.run(suite()); }
-
runAndWait
Runs a single test and waits until the user types RETURN. -
testFailed
- Specified by:
testFailed
in classBaseTestRunner
-
testStarted
- Specified by:
testStarted
in classBaseTestRunner
-
testEnded
- Specified by:
testEnded
in classBaseTestRunner
-
createTestResult
Creates the TestResult to be used for the test run. -
doRun
-
doRun
-
pause
protected void pause(boolean wait) -
main
-
start
Starts a test run. Analyzes the command line arguments and runs the given test suite.- Throws:
Exception
-
runSingleMethod
- Throws:
Exception
-
runFailed
Description copied from class:BaseTestRunner
Override to define how to handle a failed loading of a test suite.- Specified by:
runFailed
in classBaseTestRunner
-
setPrinter
-