[英]IntelliJ fails to load JUnit5 after migration
我正在试验我认为纯粹与Intellij相关的问题(尽管我不知道如何解决它,也不知道它来自哪里)。 我基本上按照本教程将测试从 JUnit 4 迁移到 5。
在迁移结束时,我现在在pom.xml
中有以下依赖项
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.6.3</version>
<scope>test</scope>
</dependency>
并且不同的测试类现在使用
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.Test;
在 IntelliJ 中运行测试时,我不断收到Cannot resolve symbol 'jupiter'
。 但是,在我的 CI 管道中一切正常???..(所以 IntelliJ 中可能有问题)。 无论建议的修复操作(分别Add JUnit 5.4 to classpath
并Add Maven dependencies
),我一直得到相同的结果。 下一个是什么?
有趣的是,变化似乎并没有反映在cockpit.iml上,因为它仍然包含
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
并且没有提到 JUnit 5. 这两个问题是否相关?
org.junit.platform
: junit-platform-launcher
File | Invalidate Caches
File | Invalidate Caches
源无效.idea
和cockpit.iml
以重新导入所有内容。某处不匹配,但我不知道在哪里
完全相同的问题。 我将 Junit 添加到 Maven pom 文件并修复它。
事实证明: pom.xml
某处的语法错误阻止了IntelliJ正确下载新的依赖项(或者看起来如此)。 刷新 maven deps按钮点击后消失但库没有下载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.