java – How to run a suite group in JUnit?


I have the following suites below:

// this other matters
public class MySuiteA {}

// this other matters
public class MySuiteB {}

How would I make a suite or test that MySuiteA and MySuiteB ?


Nothing prevents you from creating a suite of suites:

@SuiteClasses({ com.package1.MySuiteA.class,
                com.package2.MySuiteB.class })
public class RunAllTests {


Reference: Launch Suite classes using another Suite class

On the other hand, the fact that you are trying to group Suites triggers my spider-sense . Do you really need suites of suites? What's your goal?

Perhaps you are looking to split your tests according to some criteria:

  • To categorize tests (eg fast and slow) and choose which ones you want to include/exclude from a Suite have a look at the Categories functionality.
  • If you want to run tests against a certain Maven profile, the Categories functionality pairs very well with the Profiles functionality. For more information see the article Using JUnit @Category and Maven profiles to get stable test suites .

If you give more details about the problem you are trying to solve I would be happy to help you with further suggestions.

Scroll to Top