开发者

Eclipse - How to run 2 junit tests

开发者 https://www.devze.com 2023-02-03 16:33 出处:网络
I wo开发者_JS百科uld like to run 2 tests methods using eclipse. I can run 1 test, and whole test class, but 2 test method is impossible.

I wo开发者_JS百科uld like to run 2 tests methods using eclipse. I can run 1 test, and whole test class, but 2 test method is impossible.

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

@RunWith(Suite.class)
@Suite.SuiteClasses({
        JunitTest1.class,
        JunitTest2.class
})


You can also select your test source directory or a package and right-click it and select "Run As -> Junit Test" to execute all tests in that source directory or package.


Mark as comment the test methods you don't like to run. Run the class as J-Unit test.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号