Hum*_*Bee 7 intellij-idea junit5
我正在尝试在 Intellij 中运行测试,该测试曾经在 Spring Boot 2.2.x 早期工作过。我最近升级到 spring boot 2.3.9。当我尝试从运行配置运行测试时,它不会运行测试并抛出错误:
“无法解析 junit 平台启动器 1.6.3 intellij”。
但是,如果我在 cli 中运行测试,它工作正常。
Hum*_*Bee 10
事实证明,为了在 IntelliJ 中运行 Junit5 测试,需要添加 junit5-platform-launcher 依赖项。
https://junit.org/junit5/docs/current/user-guide/#running-tests-ide-intellij-idea
在 pom.xml 中显式添加此依赖项,它将解决问题。
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
对于 IntelliJ Idea 2021.1,我修复了类似的问题:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
也许更好的解决方法是:
<dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit/junit-bom -->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.7.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6038 次 |
| 最近记录: |