程序包 org.junit.runner
类 JUnitCore
- java.lang.Object
- org.junit.runner.JUnitCore
public class JUnitCore extends Object
JUnitCoreis 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, runjava org.junit.runner.JUnitCore TestClass1 TestClass2 .... For one-shot test runs, use the static methodrunClasses(Class[]). If you want to add special listeners, create an instance ofJUnitCorefirst and use it to run the tests.- 从以下版本开始:
- 4.0
- 另请参阅:
Result,RunListener,Request
构造器概要
构造器 构造器 说明 JUnitCore()
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 voidaddListener(RunListener listener)Add a listener to be notified as the tests run.StringgetVersion()static voidmain(String... args)Run the tests contained in the classes named in theargs.voidremoveListener(RunListener listener)Remove a listener.Resultrun(Class<?>... classes)Run all the tests inclasses.Resultrun(junit.framework.Test test)Run all the tests contained in JUnit 3.8.xtest.Resultrun(Computer computer, Class<?>... classes)Run all the tests inclasses.Resultrun(Request request)Run all the tests contained inrequest.Resultrun(Runner runner)Do not use.static ResultrunClasses(Class<?>... classes)Run the tests contained inclasses.static ResultrunClasses(Computer computer, Class<?>... classes)Run the tests contained inclasses.
构造器详细资料
JUnitCore
public JUnitCore()
方法详细资料
main
public static void main(String... args)
Run the tests contained in the classes named in theargs. 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
runClasses
public static Result runClasses(Class<?>... classes)
Run the tests contained inclasses. Write feedback while the tests are running and write stack traces for all failed tests after all tests complete. This is similar tomain(String[]), but intended to be used programmatically.- 参数:
classes- Classes in which to find tests- 返回:
- a
Resultdescribing the details of the test run and the failed tests.
runClasses
public static Result runClasses(Computer computer, Class<?>... classes)
Run the tests contained inclasses. Write feedback while the tests are running and write stack traces for all failed tests after all tests complete. This is similar tomain(String[]), but intended to be used programmatically.- 参数:
computer- Helps construct Runners from classesclasses- Classes in which to find tests- 返回:
- a
Resultdescribing the details of the test run and the failed tests.
getVersion
public String getVersion()
- 返回:
- the version number of this release
run
public Result run(Class<?>... classes)
Run all the tests inclasses.- 参数:
classes- the classes containing tests- 返回:
- a
Resultdescribing the details of the test run and the failed tests.
run
public Result run(Computer computer, Class<?>... classes)
Run all the tests inclasses.- 参数:
computer- Helps construct Runners from classesclasses- the classes containing tests- 返回:
- a
Resultdescribing the details of the test run and the failed tests.
run
public Result run(Request request)
Run all the tests contained inrequest.- 参数:
request- the request describing tests- 返回:
- a
Resultdescribing 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.xtest. Here for backward compatibility.- 参数:
test- the old-style test- 返回:
- a
Resultdescribing the details of the test run and the failed tests.
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