Methods Summary |
---|
protected junit.framework.TestResult | createTestResult()Creates the TestResult to be used for the test run.
return new TestResult();
|
public junit.framework.TestResult | doRun(junit.framework.Test test)
return doRun(test, false);
|
public junit.framework.TestResult | doRun(junit.framework.Test suite, boolean wait)
TestResult result= createTestResult();
result.addListener(fPrinter);
long startTime= System.currentTimeMillis();
suite.run(result);
long endTime= System.currentTimeMillis();
long runTime= endTime-startTime;
fPrinter.print(result, runTime);
pause(wait);
return result;
|
public TestSuiteLoader | getLoader()Always use the StandardTestSuiteLoader. Overridden from
BaseTestRunner.
return new StandardTestSuiteLoader();
|
public static void | main(java.lang.String[] args)
TestRunner aTestRunner= new TestRunner();
try {
TestResult r= aTestRunner.start(args);
if (!r.wasSuccessful())
System.exit(FAILURE_EXIT);
System.exit(SUCCESS_EXIT);
} catch(Exception e) {
System.err.println(e.getMessage());
System.exit(EXCEPTION_EXIT);
}
|
protected void | pause(boolean wait)
if (!wait) return;
fPrinter.printWaitPrompt();
try {
System.in.read();
}
catch(Exception e) {
}
|
public static void | run(java.lang.Class testClass)Runs a suite extracted from a TestCase subclass.
run(new TestSuite(testClass));
|
public static junit.framework.TestResult | run(junit.framework.Test test)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());
}
TestRunner runner= new TestRunner();
return runner.doRun(test);
|
public static void | runAndWait(junit.framework.Test suite)Runs a single test and waits until the user
types RETURN.
TestRunner aTestRunner= new TestRunner();
aTestRunner.doRun(suite, true);
|
protected void | runFailed(java.lang.String message)
System.err.println(message);
System.exit(FAILURE_EXIT);
|
public void | setPrinter(junit.textui.ResultPrinter printer)
fPrinter= printer;
|
protected junit.framework.TestResult | start(java.lang.String[] args)Starts a test run. Analyzes the command line arguments
and runs the given test suite.
String testCase= "";
boolean wait= false;
for (int i= 0; i < args.length; i++) {
if (args[i].equals("-wait"))
wait= true;
else if (args[i].equals("-c"))
testCase= extractClassName(args[++i]);
else if (args[i].equals("-v"))
System.err.println("JUnit "+Version.id()+" by Kent Beck and Erich Gamma");
else
testCase= args[i];
}
if (testCase.equals(""))
throw new Exception("Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class");
try {
Test suite= getTest(testCase);
return doRun(suite, wait);
}
catch(Exception e) {
throw new Exception("Could not create and run test suite: "+e);
}
|
public void | testEnded(java.lang.String testName)
|
public void | testFailed(int status, junit.framework.Test test, java.lang.Throwable t)
|
public void | testStarted(java.lang.String testName)
|