is a facade for running tests. It supports running JUnit 4 tests,
JUnit 3.8.x tests, and mixtures. To run tests from the command line, run
.
If you want to add special listeners,
create an instance of
first and use it to run the tests.
| Method from org.junit.runner.JUnitCore Detail: |
public void addListener(RunListener listener) {
fNotifier.addListener(listener);
}
Add a listener to be notified as the tests run. |
static Computer defaultComputer() {
return new Computer();
}
|
public String getVersion() {
return Version.id();
}
|
public static void main(String args) {
runMainAndExit(new RealSystem(), args);
}
Run the tests contained in the classes named in the args.
If all tests run successfully, exit with a status of 0. Otherwise exit with a status of 1.
Write feedback while tests are running and write
stack traces for all failed tests after the tests all complete. |
public void removeListener(RunListener listener) {
fNotifier.removeListener(listener);
}
|
public Result run(Class<?> classes) {
return run(Request.classes(defaultComputer(), classes));
}
Run all the tests in classes. |
public Result run(Request request) {
return run(request.getRunner());
}
Run all the tests contained in request. |
public Result run(Test test) {
return run(new JUnit38ClassRunner(test));
}
Run all the tests contained in JUnit 3.8.x test. Here for backward compatibility. |
public Result run(Runner runner) {
Result result= new Result();
RunListener listener= result.createListener();
fNotifier.addFirstListener(listener);
try {
fNotifier.fireTestRunStarted(runner.getDescription());
runner.run(fNotifier);
fNotifier.fireTestRunFinished(result);
} finally {
removeListener(listener);
}
return result;
}
Do not use. Testing purposes only. |
public Result run(Computer computer,
Class<?> classes) {
return run(Request.classes(computer, classes));
}
Run all the tests in classes. |
public static Result runClasses(Class<?> classes) {
return new JUnitCore().run(defaultComputer(), classes);
}
Run the tests contained in classes. Write feedback while the tests
are running and write stack traces for all failed tests after all tests complete. This is
similar to #main(String[]) , but intended to be used programmatically. |
public static Result runClasses(Computer computer,
Class<?> classes) {
return new JUnitCore().run(computer, classes);
}
Run the tests contained in classes. Write feedback while the tests
are running and write stack traces for all failed tests after all tests complete. This is
similar to #main(String[]) , but intended to be used programmatically. |
public Result runMain(JUnitSystem system,
String args) {
system.out().println("JUnit version " + Version.id());
List< Class< ? > > classes= new ArrayList< Class< ? > >();
List< Failure > missingClasses= new ArrayList< Failure >();
for (String each : args)
try {
classes.add(Class.forName(each));
} catch (ClassNotFoundException e) {
system.out().println("Could not find class: " + each);
Description description= Description.createSuiteDescription(each);
Failure failure= new Failure(description, e);
missingClasses.add(failure);
}
RunListener listener= new TextListener(system);
addListener(listener);
Result result= run(classes.toArray(new Class[0]));
for (Failure each : missingClasses)
result.getFailures().add(each);
return result;
}
Do not use. Testing purposes only. |
public static void runMainAndExit(JUnitSystem system,
String args) {
Result result= new JUnitCore().runMain(system, args);
system.exit(result.wasSuccessful() ? 0 : 1);
}
Do not use. Testing purposes only. |