如何摆脱 java.lang.Exception: ... 将自身包含为 SuiteClass
How to get rid of java.lang.Exception: ... contains itself as a SuiteClass
我正在使用 classpath suite library 自动 运行 项目中的所有测试,效果很好。
@RunWith(ClasspathSuite.class)
@SuiteTypes({RUN_WITH_CLASSES, TEST_CLASSES, JUNIT38_TEST_CLASSES})
@ClassnameFilters({"com.foo.bar.*"})
public class AllTests {
}
然而,每次我 运行 AllTests
我都会得到这个错误:
java.lang.Exception: class 'com.foo.bar.AllTests' (possibly indirectly) contains itself as a SuiteClass
有什么办法可以解决这个问题吗?
是的,我读过 JUnit: (possibly indirectly) contains itself as a SuiteClass 但没有找到答案,因为无论如何我都没有继承 AllTests
。
只需将您的 AllTests
class 移至包裹 com.foo
。
您已选择 SuiteTypes=RUN_WITH_CLASSES
(并将目标包设置为 com.foo.bar
),因此您的 AllTests
一遍又一遍地运行 AllTests
。
我正在使用 classpath suite library 自动 运行 项目中的所有测试,效果很好。
@RunWith(ClasspathSuite.class)
@SuiteTypes({RUN_WITH_CLASSES, TEST_CLASSES, JUNIT38_TEST_CLASSES})
@ClassnameFilters({"com.foo.bar.*"})
public class AllTests {
}
然而,每次我 运行 AllTests
我都会得到这个错误:
java.lang.Exception: class 'com.foo.bar.AllTests' (possibly indirectly) contains itself as a SuiteClass
有什么办法可以解决这个问题吗?
是的,我读过 JUnit: (possibly indirectly) contains itself as a SuiteClass 但没有找到答案,因为无论如何我都没有继承 AllTests
。
只需将您的 AllTests
class 移至包裹 com.foo
。
您已选择 SuiteTypes=RUN_WITH_CLASSES
(并将目标包设置为 com.foo.bar
),因此您的 AllTests
一遍又一遍地运行 AllTests
。