Eclipse - How to run 2 junit tests

I would like to run 2 test methods using eclipse. I can run 1 test and the entire test class, but 2 test methods are not possible.

Any idea how I can do this?

+3
source share
4 answers

write a test suite that includes your tests, for example

public static Test suite(){
  TestSuite suite = new TestSuite();
  suite.addTest(new BookTest("testEquals"));
  suite.addTest(new BookTest("testBookAdd"));
  return suite;
}

and run this package instead of single tests. See this tutorial for more details .

+6
source

If you want to use JUnit4 syntax try

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

"Run As → Junit Test" .

0

Mark test methods you do not want to run as comments. Run the class as a J-Unit test.

0
source

Source: https://habr.com/ru/post/1784981/


All Articles