簡體   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