Every second Junit 5 test execution fails with message 'No tests found with test runner JUnit 5' [message #1819204] |
Fri, 10 January 2020 02:13 |
hue nguyen Messages: 3 Registered: January 2020 |
Junior Member |
|
|
Hello,
I am facing a problem with the execution of a JUnit 5 launch configuration in eclipse.
The project in which the source code as well as the test code resides is a maven project.
The launch configuration seems to be setup correctly, because right after a build the tests are executed without a problem.
If I execute the same launch configuration a second time, this results in the above mentioned error producing the following stack trace in the console window:
Code: [Select all] [Show/ hide]
java.lang.NoClassDefFoundError: org/junit/platform/commons/util/Preconditions
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:83)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:67)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.<init>(JUnit5TestLoader.java:34)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:370)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:365)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:309)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:224)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:208)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.commons.util.Preconditions
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more
A subsequent execution of the launch configuration will again work correctly.
This goes on and on - one execution works fine, the subsequent one fails.
As you can imagine, this is a pretty annoying situation.
I traced the problem a bit deeper and can tell, that the given stack trace only shows a symptom not the root cause.
The class Preconditions present in the local maven repository (in package junit-platform-commons) and this package is part of recursive maven dependencies.
As far as I could identify the problem so far, the classpaths of the URLClassLoaders are not set correctly in the failing case.
In the working case, I see two of the ClassLoaders - one containing the paths for the java runtime jars and the second containing my project jar and all the jars of my maven dependencies in the local .m2 repository.
In the failing case, I see again two ClassLoaders - the first one again with the paths for the java runtime, but the second containing my project jar and instead of my maven dependencies only some paths to
Code: [Select all] [Show/ hide]
eclipse/configuration/org.eclipse.osgi/1135/0/.cp/
eclipse/configuration/org.eclipse.osgi/1137/0/.cp/
eclipse/configuration/org.eclipse.osgi/1373/0/.cp/
eclipse/configuration/org.eclipse.osgi/1138/0/.cp/lib/javaagent-shaded.jar
As far as I understand, the classpath setting in the launch configuration has a immediate effect on the paths in these URLClassLoaders.
But this seems to be broken in my case every second execution.
Has anyone observed the same behavior or even better has a solution or hint for me how to solve this problem?
Looking forward to your help,
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02742 seconds