简体   繁体   English

如何摆脱java.lang.Exception:…将自身包含为SuiteClass

[英]How to get rid of java.lang.Exception: … contains itself as a SuiteClass

I'm using the classpath suite library to automtically run all tests in a project, which works fine. 我正在使用classpath套件库自动运行项目中的所有测试,效果很好。

@RunWith(ClasspathSuite.class)
@SuiteTypes({RUN_WITH_CLASSES, TEST_CLASSES, JUNIT38_TEST_CLASSES})
@ClassnameFilters({"com.foo.bar.*"})
public class AllTests {
}

However, everytime I run AllTests I get this error: 但是,每次我运行AllTests ,都会出现此错误:

java.lang.Exception: class 'com.foo.bar.AllTests' (possibly indirectly) contains itself as a SuiteClass

Any ideas how to get rid of this? 任何想法如何摆脱这一点?

And yes, I've read JUnit: (possibly indirectly) contains itself as a SuiteClass but did not find an answer, since I'm not inheriting from AllTests in anyway. 是的,我已经阅读了JUnit :(可能是间接地)将自己包含为SuiteClass,但没有找到答案,因为无论如何我都不从AllTests继承。

Just move your AllTests class to package com.foo . 只需将您的AllTests类移动到com.foocom.foo

You have selected SuiteTypes=RUN_WITH_CLASSES (and set target package to com.foo.bar ), so your AllTests runs AllTests over and over. 您选择SuiteTypes=RUN_WITH_CLASSES (和设定的目标包com.foo.bar ),让您的AllTests运行AllTests一遍又一遍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM