[英]"No junit.jar" error in Intellij when right clicking a folder, but not when running individual classes of tests
Spring boot is using JUnit 5. 如果你使用 spring boot initializr 網站,你應該有這樣的依賴。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
您在測試中使用了 JUnit 4 還是 5? 您可以嘗試更新 IntelliJ 或 JUnit 插件,這可能會解決您的問題。
我遇到了這個問題,這就是我解決它的方式:
語境:
dependencyManagement
中添加junit
的 maven 依賴(而不是dependencies
,它們的區別可以在這里找到)PS:如果您的情況與以上上下文不符,此方案可能無法解決您的問題。
腳步
我設法通過在根 pom.xml 文件中添加 Junit Maven 依賴關系來解決該問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.