0

Group JUnit Test Cases using @Suite.SuiteClasses

Grouping Unit Tests

At times there are certain set of unit tests we want to execute automatically. These tests may be critical or have been simply grouped for some reasons. To group JUnit test cases, we use @Suite.SuiteClasses annotation.

Environment

  1. Eclipse Mars.1
  2. JDK 7
  3. Ubuntu 14.04 LTS
  4. JUnit 4

Using @Suite.SuiteClasses

To group some tests together, we proceed by creating an empty class annotated with @Suite.SuiteClasses and indicating which test classes to include.

That’s all!

To run only the set of tests via Maven, use:

As you can see TestCase003 was never executed.

screenshot_from_2015-11-25_225707

screenshot_from_2015-11-25_225741

Download the Codes

https://github.com/Turreta/java-junit4-suite-example

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert