Test framework quit unexpectedly - can't find a class by name

Answered

The error message

```

Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/platform/launcher/TestIdentifier
    at com.intellij.junit5.JUnit5IdeaTestRunner.<clinit>(JUnit5IdeaTestRunner.java:72)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:315)
    at com.intellij.rt.junit.JUnitStarter.getAgentClass(JUnitStarter.java:244)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:225)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.launcher.TestIdentifier
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 6 more

```

 

Steps to reproduce

Create a brand new IDE plugin

Update build.gradle.kts per instructions here: https://kotlinlang.org/docs/jvm-test-using-junit.html#add-the-code-to-test-it

Create the tests using the UI, per the instructions

Try to run the tests

 

The above steps _will_ work with a different type of project.

The issue _seems_ to stem from the intellij plugin 

id("org.jetbrains.intellij") version "1.8.0"

If i delete this (and all associated elements from the gradle), i can run tests.

Any advice on how to make these two co-exist would be nice.

Thanks

 

IntelliJ IDEA 2022.2.2 (Ultimate Edition)
Build #IU-222.4167.29, built on September 13, 2022
Licensed to Jeffrey Reynolds
Subscription is active until May 15, 2023.
Runtime version: 17.0.4+7-b469.53 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.19.9-zen1-1-zen
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 32
Non-Bundled Plugins:
    org.antlr.intellij.plugin (1.19.2)
    org.jetbrains.idea.grammar (2021.1.2)
    PsiViewer (222-SNAPSHOT)
    com.intellij.bigdatatools (222.3345.33)

Kotlin: 222-1.7.10-release-334-IJ4167.29
Current Desktop: KDE

0
4 comments

Hi Jeffrey,

Please try the newest Gradle IntelliJ Plugin: 1.9.0 and let us know if it solves the issue.

If the issue still occurs, it would be perfect if you shared the project where we can quickly reproduce it. Thanks.

0

Hi,

Upgrading to 1.9.0 did not make a difference.  

I've uploaded a sample project that should recreate the issue here: https://github.com/taekahn/intellij-plugin-bug

Please let me know if you have any issues.

Thank you.

0

Hi Jeffrey,

Please add the following dependency:

testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.9.1")

Also, the depdency to junit-jupiter seems unnecessary, so please remove it:

testImplementation("org.junit.jupiter:junit-jupiter:4.8.1")
1

That seems to work.

Thanks!

0

Please sign in to leave a comment.