小智 7
我的情况有所不同,但我遇到了相同的 junit 错误。我使用以下方法在 junit 依赖项中遇到冲突:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
有了这个,你必须使用
import org.junit.jupiter.api.Test;
Run Code Online (Sandbox Code Playgroud)
代替
import org.junit.Test;
Run Code Online (Sandbox Code Playgroud)
一种可能性是 Eclipse 的 JUnit 运行程序对该方法的存在感到困惑main
,并运行该方法而不是测试方法。
尝试注释掉该main
方法。IMO,它根本不应该在那里。
(顺便说一句, main 方法对我来说看起来不正确。我原以为它会实例化 aTestSuite
以单元测试类作为参数,但你似乎给它提供了被测试的类。那不会有任何“测试”方法,这可以解释为什么没有运行测试......)