?? testrunner.java
字號:
package junit.textui;
import java.io.PrintStream;
import junit.framework.*;
import junit.textui.*;
/**
* A command line based tool to run tests.
* <pre>
* java junit.textui.TestRunner [-wait] TestCaseClass
* </pre>
* TestRunner expects the name of a TestCase class as argument.
* If this class defines a static <code>suite</code> method it
* will be invoked and the returned test is run. Otherwise all
* the methods starting with "test" having no arguments are run.
* <p>
* When the wait command line argument is given TestRunner
* waits until the users types RETURN.
* <p>
* TestRunner prints a trace as the tests are executed followed by a
* summary at the end.
*/
public class TestRunner extends BaseTestRunner {
private ResultPrinter fPrinter = new ResultPrinter(System.out);
/**
* Constructs a TestRunner.
*/
public TestRunner() {
}
/**
* Creates the TestResult to be used for the test run.
*/
protected TestResult createTestResult() {
return new TestResult();
}
public TestResult doRun(Test suite) {
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);
return result;
}
/**
* Starts a test run. Analyzes the command line arguments
* and runs the given test suite.
*/
protected TestResult start(String args[]) throws Exception {
String testCase = args[0];
try {
Test suite = getTest(testCase);
return doRun(suite);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
public static void main(String args[]) {
TestRunner aTestRunner = new TestRunner();
try {
TestResult r = aTestRunner.start(args);
} catch (Exception e) {
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -