JUnitCore (JUnit API)

Junit


org.junit.runner Class JUnitCore

java.lang.Object
  extended by org.junit.runner.JUnitCore

public class JUnitCore
extends Object

JUnitCore 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 java org.junit.runner.JUnitCore TestClass1 TestClass2 .... For one-shot test runs, use the static method runClasses(Class[]). If you want to add special listeners, create an instance of JUnitCore first and use it to run the tests.

另请参见:
Result, RunListener, Request

构造器摘要
JUnitCore()
          Create a new JUnitCore to run tests.
 
方法摘要
 void addListener(RunListener listener)
          Add a listener to be notified as the tests run.
 String getVersion()
           
static void main(String... args)
          Run the tests contained in the classes named in the args.
 void removeListener(RunListener listener)
          Remove a listener.
 Result run(Class<?>... classes)
          Run all the tests in classes.
 Result run(Computer computer, Class<?>... classes)
          Run all the tests in classes.
 Result run(Request request)
          Run all the tests contained in request.
 Result run(Runner runner)
          Do not use.
 Result run(junit.framework.Test test)
          Run all the tests contained in JUnit 3.8.x test.
static Result runClasses(Class<?>... classes)
          Run the tests contained in classes.
static Result runClasses(Computer computer, Class<?>... classes)
          Run the tests contained in classes.
 Result runMain(org.junit.internal.JUnitSystem system, String... args)
          Do not use.
static void runMainAndExit(org.junit.internal.JUnitSystem system, String... args)
          Do not use.
 
类方法继承: java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造器详细信息

JUnitCore

public JUnitCore()
Create a new JUnitCore to run tests.

方法详细信息

main

public static void main(String... 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.

参数:
args - names of classes in which to find tests to run

runMainAndExit

public static void runMainAndExit(org.junit.internal.JUnitSystem system,
                                  String... args)
Do not use. Testing purposes only.

参数:
system -

runClasses

public static Result runClasses(Computer computer,
                                Class<?>... 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.

参数:
computer - Helps construct Runners from classes
classes - Classes in which to find tests
返回:
a Result describing the details of the test run and the failed tests.

runClasses

public static Result runClasses(Class<?>... 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.

参数:
classes - Classes in which to find tests
返回:
a Result describing the details of the test run and the failed tests.

runMain

public Result runMain(org.junit.internal.JUnitSystem system,
                      String... args)
Do not use. Testing purposes only.

参数:
system -

getVersion

public String getVersion()
返回:
the version number of this release

run

public Result run(Class<?>... classes)
Run all the tests in classes.

参数:
classes - the classes containing tests
返回:
a Result describing the details of the test run and the failed tests.

run

public Result run(Computer computer,
                  Class<?>... classes)
Run all the tests in classes.

参数:
computer - Helps construct Runners from classes
classes - the classes containing tests
返回:
a Result describing the details of the test run and the failed tests.

run

public Result run(Request request)
Run all the tests contained in request.

参数:
request - the request describing tests
返回:
a Result describing the details of the test run and the failed tests.

run

public Result run(junit.framework.Test test)
Run all the tests contained in JUnit 3.8.x test. Here for backward compatibility.

参数:
test - the old-style test
返回:
a Result describing the details of the test run and the failed tests.

run

public Result run(Runner runner)
Do not use. Testing purposes only.


addListener

public void addListener(RunListener listener)
Add a listener to be notified as the tests run.

参数:
listener - the listener to add
另请参见:
RunListener

removeListener

public void removeListener(RunListener listener)
Remove a listener.

参数:
listener - the listener to remove