Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory

We Are Going To Discuss About Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory. So lets Start this Java Article.

Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory

Advertisements
  1. Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory

    In my case, the problem was myself and no IDE like Eclipse. I've imported the JUnit 4 Test class.
    So do NOT import this one:
    import org.junit.Test // JUnit 4
    But DO import that one:
    import org.junit.jupiter.api.Test // JUnit 5

  2. Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory

    In my case, the problem was myself and no IDE like Eclipse. I've imported the JUnit 4 Test class.
    So do NOT import this one:
    import org.junit.Test // JUnit 4
    But DO import that one:
    import org.junit.jupiter.api.Test // JUnit 5

Solution 1

Advertisements

I fixed the issue by right clicking the test and selecting ‘Run Configurations’ and changing the “Test runner:” selection to ‘JUnit 4’ as shown here:

Screenshot of run configruations

I ran the test again and it worked.

Original Author stringVector Of This Content

Solution 2

Advertisements

I have the same issue with STS 3.9.1. It seems like an Eclipse bug, however, to fix this you can add a test dependency junit-platform-launcher to your project (https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher)

This is how I did for my project which uses gradle:

dependencies {
    // other stuff here

    testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "5.${junit5MinorVersion}"
    testCompile group: 'org.junit.platform', name: 'junit-platform-launcher', version: "1.${junit5MinorVersion}"
}

gradle.properties file:

junit5MinorVersion=1.0

I believe the same applies if you see this exception while using IntelliJ IDEA.

Original Author Andrii Karaivanskyi Of This Content

Solution 3

Advertisements

In my case, the problem was myself and no IDE like Eclipse. I’ve imported the JUnit 4 Test class.

So do NOT import this one:

import org.junit.Test  // JUnit 4

But DO import that one:

import org.junit.jupiter.api.Test // JUnit 5

Original Author armin.miedl Of This Content

Solution 4

Advertisements

SIMPLE FIX: (Add JUnit 5 Library)

INSTRUCTIONS:

  • Right click on project -> Build Path -> Configure Build Path
  • In the pop-up -> Add Library -> JUnit -> JUnit 5 -> Finish -> Apply
  • You should see the JUnit 5 Library (and its jars) added to your project
  • Right click on project -> Maven -> Update Project -> OK

Original Author Jerry Carney Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment