Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

failed to resolve junit platform launcher 1.6.3 intellij

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.

like image 223
Humble Bee Avatar asked Feb 22 '21 11:02

Humble Bee


People also ask

What is JUnit platform launcher?

platform. launcher. Public API for configuring and launching test plans. This API is typically used by IDEs and build tools.

Where is JUnit version in Intellij?

You can use Ctrl+F to find any "junit" references.


Video Answer


3 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>
like image 130
Humble Bee Avatar answered Oct 19 '22 18:10

Humble Bee


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

like image 12
Rayon Avatar answered Oct 19 '22 20:10

Rayon


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

like image 6
razvanone Avatar answered Oct 19 '22 20:10

razvanone