2

I want to add a subtest, FailingIO, to FailingTest while inheriting the parent's useful methods

@RunWith(Suite.class)
@Suite.SuiteClasses({FailingTest.FailingIO.class})
class FailingTest {

  @Test
  test1() {}


  static class FailingIO extends FailingTest {

I am getting JUnit: (possibly indirectly) contains itself as a SuiteClass because the annotations are also inherited, I guess. Is there a way to inherit only the methods and leave the annotations to the parent?

I see in Eclipse that Suite.SuiteClasses has the @Inherited but JUnit API has not such attribute. What is going on? What is the JUnit versioning policy regarding the option?

update I see that it is possible to construct a test suite dynamically, e.g. here, here and here. But when do I exploit that for extending FailingTest with FailingIO? Where do I define this code and who will consume the produced subsuite?

update I have checked the HierarchicalContextRunner. It does not contain itself but sadly executes the parent-inherited tests.

Community
  • 1
  • 1
Val
  • 1
  • 8
  • 40
  • 64
  • Why on earth do you want the inner class to be a subclass of the outer class, where that class is a test suite? Is this just the “inheritance for convenience” antipattern? – Donal Fellows Sep 17 '13 at 15:16
  • By nesting I enforce the fact that subtest will be called only as part of the parent test. By inheritance, I make all items to belong to the same type. Child nodes in the tree share the common properties with the parent. Is it bad because somebody has invented an antipattern? Do they tell that convinience is bad? Tell those people to stop littering programmer heads with garbage and distracting people them reality. – Val Sep 17 '13 at 15:48

0 Answers0