I need the following test
@runwith(cache, memory) class CollectionA is -- this is a suite (aka folder) class Cache { -- this is a sub-suite (aka folder) @test testCache1() -- this is a method (aka file) @test testCache2() @test testCache3() } class RAM { -- this is a sub-suite (aka folder) @test testRAM1() @test testRAM2() } @test testIO() @test testKeyboard() @test testMouse() @test testMonitor() @test testPower() @test testBoot() Please note that only Cache and RAM need to be grouped. The hierarchy helps to fight the complexity and run related tests, e.g. Cache subsystem, alone, when necessary. The problem that is as soon I use @runwith to do that grouping, all the single test methods besides the RAM and Cache collections are ignored by JUnit. It seems that you cannot have sibling files and folders in JUnit design. The comments in the official example of grouping also hints that
@RunWith(Suite.class) @Suite.SuiteClasses({ TestA.class, TestA.class }) public class FeatureTestSuite { // the class remains empty, // used only as a holder for the above annotations // HEY!!! WHAT ABOUT MY @Tests HERE? } The answers say that whether I need to wrap every single test, e.g. testPower into their singletone suit or flatten the suite - get rid if the hierarchy completely.
So, is it right that JUnit is designed to disallow mixing single files (@test methods) with the folders (@runwith suites)? Why? How can this be worked around? Might be there is an alternative to @runwith.Suite?
Enclosedrunner, not theSuiterunner. Using aSuiteof separate classes allows you to 1: have smaller files 2: run an individual test