You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Encountering this bug as well — along with the ~50 students in a Java-based course for whom this bug is their introduction to both Java and VS Code. 😬
I tried installing the vsix fix attached above, and got this when trying to run tests:
java.lang.NoClassDefFoundError: org/junit/platform/commons/util/ClassNamePatternFilterUtils
at org.junit.platform.launcher.core.LauncherFactory.loadAndFilterTestExecutionListeners(LauncherFactory.java:191)
at org.junit.platform.launcher.core.LauncherFactory.registerTestExecutionListeners(LauncherFactory.java:179)
at org.junit.platform.launcher.core.LauncherFactory.createDefaultLauncher(LauncherFactory.java:137)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:125)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:109)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.<init>(JUnit5TestLoader.java:37)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) NativeConstructorAccessorImpl.java:77
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) DelegatingConstructorAccessorImpl.java:45
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) Constructor.java:499
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) ReflectAccess.java:128
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347) ReflectionFactory.java:347
at java.base/java.lang.Class.newInstance(Class.java:645) Class.java:645
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:371)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:366)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:310)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:225)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.commons.util.ClassNamePatternFilterUtils
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) BuiltinClassLoader.java:641
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ClassLoaders.java:188
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ClassLoader.java:520
... 18 more
Downgrading both the Language Support for Java and Test Runner for Java extensions to the previous release fixes the issue for me:
Replying to myself: No, I see from experimentation that pinning to an old version of JUnit Jupier in fact causes the problem. Simply updating the Jupiter version number to 5.9.+ fixes the problem, without having to add the junit-platform-commons dependency.
It seems like a bug that vscode-java-test can’t run tests for projects that specify older JUnit versions. After all, the point of specifying a version is precisely to avoid future breakages like this. Should I file that as a new issue?
Activity
mishi321 commentedon Sep 1, 2022
The same to you, the log file is here
kaipaysen commentedon Sep 1, 2022
Same here.. stuck on "Resolving launch configurations".
System : Mac OS
JDK: OpenJDK Runtime Environment (build 17.0.1+12-39)
Gradle: 7.4.2
Maven: 3.8.5
redhat.java: v1.10.0
vscjava.vscode-java-test: v0.37.0
vscjava.vscode-java-debug: v0.43.0
jdneo commentedon Sep 1, 2022
jdneo commentedon Sep 1, 2022
For anyone encountered this issue, please install vscode-java-test-0.37.2022090109.vsix.zip to see if the problem got fixed and let me know if it's possible.
I'll do some verification as well. If everything is fine, I'll plan a hotfix release tomorrow.
kaipaysen commentedon Sep 1, 2022
Great, works on my machine. Thank you very much.
pcantrell commentedon Sep 1, 2022
Encountering this bug as well — along with the ~50 students in a Java-based course for whom this bug is their introduction to both Java and VS Code. 😬
I tried installing the vsix fix attached above, and got this when trying to run tests:
Downgrading both the Language Support for Java and Test Runner for Java extensions to the previous release fixes the issue for me:
pcantrell commentedon Sep 1, 2022
Confirmed error from vsix occurs even after completely uninstalling all Java and Gradle extensions, then doing a clean install.
I installed the vsix using:
Is that the correct method?
lucidfrontier45 commentedon Sep 2, 2022
Sheng Chen (@jdneo)
Thank you for the fix. I confirmed vscode-java-test-0.37.2022090109.vsix.zip fixed the problem.
jdneo commentedon Sep 2, 2022
Paul Cantrell (@pcantrell) This is because we upgrade the bundled junit jupiter version, which has a breaking change start from 1.7.0.
What you need to do is add the dependency
org.junit.platform:junit-platform-commonsto your project.See: https://stackoverflow.com/questions/61801256/exception-in-thread-main-java-lang-noclassdeffounderror-org-junit-platform-co
jdneo commentedon Sep 2, 2022
0.37.1has been released, the problem should be gone with the latest version.pcantrell commentedon Sep 2, 2022
The
build.gradlein the project in question pins Jupiter to an older version:Shouldn’t this prevent that problem? Does the VS Code test runner simply ignore the JUnit version specified in the project file?
pcantrell commentedon Sep 2, 2022
Replying to myself: No, I see from experimentation that pinning to an old version of JUnit Jupier in fact causes the problem. Simply updating the Jupiter version number to
5.9.+fixes the problem, without having to add the junit-platform-commons dependency.It seems like a bug that vscode-java-test can’t run tests for projects that specify older JUnit versions. After all, the point of specifying a version is precisely to avoid future breakages like this. Should I file that as a new issue?
jdneo commentedon Sep 2, 2022
Paul Cantrell (@pcantrell) Please check: https://bugs.eclipse.org/bugs/show_bug.cgi?id=569860.
To fix this issue, we need to provide delegate to Gradle
pcantrell commentedon Sep 2, 2022
Thanks for the explanation. This comment echoes my thoughts quite closely. This does seem like a fundamental philosophical problem.
Fortunately I can simply upgrade JUnit in the projects in question, but at the very least, better diagnostics here would be useful.
jdneo commentedon Aug 5, 2024
The Gradle Test Delegation (both run and debug) has supported now.
To use this feature, you need to install the latest Test Runner for Java and Gradle for Java extension.
To delegate the tests to Gradle, you can set the default testing profile in Testing explorer:


If you do not want to change the default testing profile, you can trigger an one-time execution via:

