无法解析junit平台启动器1.6.3intellij
我正在尝试在 Intellij 中运行测试,该测试曾经在 Spring Boot 2.2.x 早期工作过。我最近升级到 spring boot 2.3.9。当我尝试从运行配置运行测试时,它不会运行测试并抛出错误:
“无法解析 junit 平台启动器 1.6.3 intellij”。
但是,如果我在 cli 中运行测试,它工作正常。
回答
事实证明,为了在 IntelliJ 中运行 Junit5 测试,需要添加 junit5-platform-launcher 依赖项。
https://youtrack.jetbrains.com/issue/IDEA-231927?_ga=2.5997872.2063517257.1613993298-1098513328.1597974168
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>