How to run a suite of suites in JUnit?

9

I have the following suites below:

@RunWith(Suite.class)
// this other matters
@Suite.SuiteClasses({
        TestC.class,
        TestB.class,
        TestA.class
})
public class MySuiteA {}

@RunWith(Suite.class)
// this other matters
@Suite.SuiteClasses({
        TestD.class,
        TestE.class,
        TestF.class
})
public class MySuiteB {}

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

    
asked by anonymous 31.01.2014 / 21:04

1 answer

8

Nothing prevents you from creating a suite of suites:

@RunWith(Suite.class)
@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're trying to group Suites fires my spider-sense . Do You Really Need Suite Suites? What is your goal?

Maybe you're looking to break your tests by some criteria:

  • To categorize tests (eg, quick and slow) and choose which ones you want to include / exclude from a Suite at a glance at Categories .
  • If you want to run tests according to a given Maven profile, the Categories feature works fine with the profiles feature. For more information see #

If you give more details about the problem you're trying to solve, I'll be happy to help you with more suggestions.

    
02.02.2014 / 23:53