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 #1816489] Wed, 30 October 2019 06:12 Go to next message
Frank Heister is currently offline Frank HeisterFriend
Messages: 2
Registered: October 2019
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:
 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
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,
Frank

environment:
Eclipse IDE for Java Developers
Version: 2019-09 R (4.13.0)
Build id: 20190917-1200
All plugins are up-to-date.
Re: Every second Junit 5 test execution fails with message 'No tests found with test runner JUnit 5' [message #1816693 is a reply to message #1816489] Tue, 05 November 2019 08:03 Go to previous message
Noopur Gupta is currently offline Noopur GuptaFriend
Messages: 58
Registered: December 2012
Member
Can you check if the solutions mentioned in https://bugs.eclipse.org/bugs/show_bug.cgi?id=551298 solve your issue?
Previous Topic:problem when i try to install window builder in eclipse 2019
Next Topic:Eclipse installer hangs
Goto Forum:
  


Current Time: Fri Dec 06 02:32:50 GMT 2024

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

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

Back to the top