Software Development

Group JUnit Test Cases using @Suite.SuiteClasses

Grouping Unit Tests

[wp_ad_camp_5]

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!

[wp_ad_camp_4]

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

[wp_ad_camp_2]

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like