JUnit: (possibly indirectly) contains itself as a SuiteClass

匆匆过客 提交于 2019-12-02 03:44:26

问题


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.

来源:https://stackoverflow.com/questions/18834908/junit-possibly-indirectly-contains-itself-as-a-suiteclass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!