Intellij Idea 无法解析junit platform launcher 1.6.3 intellij

ej83mcc0  于 2023-06-05  发布在  其他
关注(0)|答案(6)|浏览(584)

我尝试在Intellij中运行测试,这在Sping Boot 2.2.x中以前是可以工作的。我最近升级到了Sping Boot 2.3.9。当我尝试从Run Configurations运行测试时,它不运行测试并抛出错误:
'无法解析junit platform launcher 1.6.3 intellij'。
但是,如果我在cli中运行测试,它工作正常。

pbwdgjma

pbwdgjma1#

事实证明,为了让Junit 5测试在IntelliJ中运行,需要添加junit 5-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>
sshcrbum

sshcrbum2#

我遇到了同样的问题“无法解决junit平台启动器1.8.1”intellij。IntellJ版本:2021.3
我找到了答案here,它工作了,不需要添加任何依赖到pom。
进入设置>> HTTP代理>>选择自动检测代理设置

xeufq47z

xeufq47z3#

对于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>

也许更好的解决方法是:

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

Found the above solution on Jetbrains issue tracker

e4eetjau

e4eetjau4#

如果你没有直接的互联网连接,但是有一个像artifactory这样的仓库管理器,idea会尝试从那里解析junit-platform-launcher。确保你有一个镜像到maven中央存储库(虚拟存储库)配置和artifactory url到这个镜像是可访问的,无需身份验证(在设置的存储库“强制身份验证”应取消选中)。检查idea代理设置,如果需要,为artifactory域配置一个例外。

hm2xizp9

hm2xizp95#

在IntelliJ Idea设置中检查代理设置。我打开了代理,它解决了这个问题。

pw9qyyiw

pw9qyyiw6#

我尝试在pom.xml中添加以下依赖项,它对我有效。

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${version.junit.jupiter}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${version.junit.jupiter}</version>
<scope>test</scope>
</dependency>

相关问题