繁体   English   中英

迁移后 IntelliJ 无法加载 JUnit5

[英]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 classpathAdd Maven dependencies ),我一直得到相同的结果。 下一个是什么?

在此处输入图像描述

环境

  • 打开jdk11
  • IntelliJ 2020.3.1

有趣的是,变化似乎并没有反映在cockpit.iml上,因为它仍然包含

 <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />

并且没有提到 JUnit 5. 这两个问题是否相关?

我试过的

  • 基于此文档,我添加了org.junit.platformjunit-platform-launcher
  • 我试过File | Invalidate Caches File | Invalidate Caches无效
  • 删除.ideacockpit.iml以重新导入所有内容。

某处不匹配,但我不知道在哪里

完全相同的问题。 我将 Junit 添加到 Maven pom 文件并修复它。

https://mvnrepository.com/artifact/junit/junit/4.13.1

事实证明: pom.xml某处的语法错误阻止了IntelliJ正确下载新的依赖项(或者看起来如此)。 刷新 maven deps按钮点击后消失但库没有下载。

暂无
暂无

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

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