[英]IntelliJ fails to load JUnit5 after migration
I am experimenting what I think to be a purely Intellij related issue (though I don't know how to fix it nor where it comes from).我正在试验我认为纯粹与Intellij相关的问题(尽管我不知道如何解决它,也不知道它来自哪里)。 I basically followed this tutorial to migrate tests from JUnit 4 to 5.
我基本上按照本教程将测试从 JUnit 4 迁移到 5。
By the end of the migration, I now have the following dependencies in pom.xml
在迁移结束时,我现在在
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>
and the different Test Classes now uses并且不同的测试类现在使用
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.Test;
I keep getting Cannot resolve symbol 'jupiter'
while running tests in IntelliJ.在 IntelliJ 中运行测试时,我不断收到
Cannot resolve symbol 'jupiter'
。 However, everything is OK in my CI pipeline ???.. (so probably something wrong in IntelliJ).但是,在我的 CI 管道中一切正常???..(所以 IntelliJ 中可能有问题)。 No matter the fix actions proposed (resp.
Add JUnit 5.4 to classpath
and Add Maven dependencies
), I keep getting the same.无论建议的修复操作(分别
Add JUnit 5.4 to classpath
并Add Maven dependencies
),我一直得到相同的结果。 So what's next?下一个是什么?
Interestingly, changes do not seem to be reflected on cockpit.iml , for it still contains有趣的是,变化似乎并没有反映在cockpit.iml上,因为它仍然包含
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
and no mention of JUnit 5. Are both problems related?并且没有提到 JUnit 5. 这两个问题是否相关?
org.junit.platform
: junit-platform-launcher
org.junit.platform
: junit-platform-launcher
File | Invalidate Caches
File | Invalidate Caches
File | Invalidate Caches
sources File | Invalidate Caches
源无效.idea
and cockpit.iml
to reimport everything..idea
和cockpit.iml
以重新导入所有内容。 There is a mismatch somewhere but I can't figure where某处不匹配,但我不知道在哪里
exactly same issue.完全相同的问题。 I added the Junit to Maven pom file and it fixed it.
我将 Junit 添加到 Maven pom 文件并修复它。
https://mvnrepository.com/artifact/junit/junit/4.13.1 https://mvnrepository.com/artifact/junit/junit/4.13.1
Turns out: a syntax error somewhere in pom.xml
prevented IntelliJ from properly downloading new dependencies (or so it seems).事实证明:
pom.xml
某处的语法错误阻止了IntelliJ正确下载新的依赖项(或者看起来如此)。 The refresh maven deps button disappeared after clicking but libraries were not downloaded.刷新 maven deps按钮点击后消失但库没有下载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.