What you like to create is a mixin type, which is not supported by the JUnit runner. So yes, you are right, it is not possible out of the box.
For this purpose I created an add-on that can be used to create hierarchical contexts for your test. In my point of view this is a missing feature in JUnit and I also stay in contact to get this included into the JUnit core.
The add-on provides an HierarchicalContextRunner which allows to use inner class to group your tests into contexts. Each context can contain tests or other contexts. It also allows to have @Before, @After, @Rule methods and fields, as well as other feature like @Ignore of the standard Runner. :-)
Example:
@RunWith(HierarchicalContextRunner.class)
public class CollectionA {
public class Cache {
@Test testCache1() {...}
@Test testCache2() {...}
@Test testCache3() {...}
}
public class RAM {
@Test testRAM1() {...}
@Test testRAM2() {...}
}
@Test testIO() {...}
@Test testKeyboard() {...}
@Test Mouse() {...}
@Test testMonitor() {...}
@Test testPower() {...}
@Test testBoot() {...}
}
Give it a try: https://github.com/bechte/junit-hierarchicalcontextrunner/wiki
Votes and feedback are highly appreciated. :)