failed to resolve junit platform launcher 1.6.3 intellij

Viewed 27816

I am trying to run tests in Intellij which used to work earlier in spring boot 2.2.x. I recently upgraded to spring boot 2.3.9. When I try to run the test from Run Configurations, it doesn't run the test and throws the error:

'failed to resolve junit platform launcher 1.6.3 intellij'.

However if I run the test in cli, it works fine.

6 Answers

It turns out that, junit5-platform-launcher dependency needs to be added in order for Junit5 tests to run in IntelliJ.

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

Add this dependency explicitly in pom.xml, and it will solve the issue.

<dependency>
     <groupId>org.junit.platform</groupId>
     <artifactId>junit-platform-launcher</artifactId>
     <scope>test</scope>
</dependency>

I was facing same issue "failed to resolve junit platform launcher 1.8.1" intellij. IntellJ version: 2021.3

I found answer here and it worked, no need to add any dependency to pom.

Go to settings >> HTTP Proxy >> choose auto-detect proxy settings

enter image description here

For IntelliJ Idea 2021.1, I fixed a similar problem with:

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

Maybe an even better fix is:

<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

If you have no direct internet connection but a repository manager like artifactory, idea tries to resolve junit-platform-launcher from there. Make sure u have a mirror to maven central repository (virtual repository) configured and the artifactory url to this mirror is accessible WITHOUT authentication (in the settings for the repo "Force Authentication" should be unchecked). Check also the idea proxy settings and if needed, configure an exception for the artifactory domain.

Check your proxy settings in IntelliJ Idea settings. I turned ON the proxy and it solved the problem.

Here's the official way to do this

Maven Surefire and Maven Failsafe can run JUnit 4 based tests alongside Jupiter tests as long as you configure test scoped dependencies on JUnit 4 and the JUnit Vintage TestEngine implementation similar to the following.

<!-- ... -->
<build>
    <plugins>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.2</version>
        </plugin>
        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.22.2</version>
        </plugin>
    </plugins>
</build>
<!-- ... -->
<dependencies>
    <!-- ... -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>5.7.2</version>
        <scope>test</scope>
    </dependency>
    <!-- ... -->
</dependencies>
<!-- ... -->
Related