[英]Eclipse - How to run 2 junit tests
I would like to run 2 tests methods using eclipse. 我想用eclipse运行2个测试方法。 I can run 1 test, and whole test class, but 2 test method is impossible.
我可以运行1个测试,并且整个测试类,但是2个测试方法是不可能的。
Any idea how I can do this? 知道我怎么能这样做吗?
write a test suite which includes your tests, like 写一个包含你的测试的测试套件,比如
public static Test suite(){
TestSuite suite = new TestSuite();
suite.addTest(new BookTest("testEquals"));
suite.addTest(new BookTest("testBookAdd"));
return suite;
}
and run this suite instead of the single tests. 并运行此套件而不是单个测试。 See this tutorial for more information.
有关更多信息,请参阅本教程 。
If you want to use JUnit4 syntax then try 如果您想使用JUnit4语法,请尝试
@RunWith(Suite.class)
@Suite.SuiteClasses({
JunitTest1.class,
JunitTest2.class
})
Mark as comment the test methods you don't like to run. 将您不喜欢的测试方法标记为评论。 Run the class as J-Unit test.
将该类作为J-Unit测试运行。
您还可以选择测试源目录或包,然后右键单击它并选择“运行方式 - > Junit测试”以执行该源目录或包中的所有测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.