Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Every second Junit 5 test execution fails with message 'No tests found with test runner JUnit 5'
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 Go to next message
hue nguyen is currently offline hue nguyenFriend
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,
Re: Every second Junit 5 test execution fails with message 'No tests found with test runner JUnit 5' [message #1819207 is a reply to message #1819204] Fri, 10 January 2020 04:33 Go to previous messageGo to next message
Sarika Sinha is currently offline Sarika SinhaFriend
Messages: 132
Registered: February 2010
Location: Bangalore, India
Senior Member
Can you please create a bug, so that it can be investigated ?
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT


Sarika Sinha
JDT Programmer
Re: Every second Junit 5 test execution fails with message 'No tests found with test runner JUnit 5' [message #1819210 is a reply to message #1819204] Fri, 10 January 2020 05:22 Go to previous message
Noopur Gupta is currently offline Noopur GuptaFriend
Messages: 58
Registered: December 2012
Member
Please check if the solution provided in https://bugs.eclipse.org/bugs/show_bug.cgi?id=551298 works for you. If not, please open a bug report.
Previous Topic:Preferences between workspaces
Next Topic:Eclipse 2019-12R
Goto Forum:
  


Current Time: Thu Dec 26 10:44:55 GMT 2024

Powered by FUDForum. Page generated in 0.02742 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top