[英]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.