NetBeans, Eclipse 和 IntelliJ Idea 都有本地的图形界面 test runners 构建器。html
单元测试提供工具去定义测试集合并能被运行 已经显示他的结果。运行测试,能够在Ide控制台看见结果。 运行这个是依赖于Java的运行方法:** org.junit.runner.JUnitCore.runClasses(TestClass1.class, ...); ** 或者, 执行命令行: java org.junit.runner.JUnitCore TestClass1 [...other test classes...]java
关于它的特性文档,能在这里找到:http://junit.org/javadoc/latest/org/junit/runner/JUnitCore.htmlgit
能够使用 JUnit4TestAdapter 适配器 使用Junit4 执行 junit3 的测试,这样能作到兼容。github
public static Test suite() { return new JUnit4TestAdapter('YourJUnit4TestClass'.class); }
若是一个类 被 @RunWith 注解 或 @RunWith 的扩展注解, JUnit 将会调用类的引用,而不是编译器编译到JUnit 中。spring
其余一些第三方比较受欢迎的Runner:api