JUnit test suite in Eclipse tutorial

JUnit test suite explained. How to create one in Eclipse and how to even easier run test cases in some package.

You can run each JUnit test using Run As -> JUnit test. But what if you have more JUnit tests and you want to run them easier?

If you want to run all JUnit tests in some package, just right click on that package and select Run As -> JUnit test. You can also select multiple packages.

If you want more fine control over JUnit test execution, create a JUnit test suite.

Right click and select New -> Other -> New JUnit Test Suite, choose name of the suite, select which test classes will be included in this test suite and select finish. This will create a class with annotation @SuiteClasses. Inside are defined JUnit test cases which will be included in this test suite. You can even call here another test suite. Now you can easily run this whole suite using Run As -> JUnit test.