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

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(
at org.junit.platform.launcher.core.LauncherFactory.create(
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.<init>(
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at java.lang.Class.newInstance(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
Caused by: java.lang.ClassNotFoundException: org.junit.platform.commons.util.Preconditions
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
... 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]

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: 116
Registered: February 2010
Location: Bangalore, India
Senior Member
Can you please create a bug, so that it can be investigated ?

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: 57
Registered: December 2012
Please check if the solution provided in works for you. If not, please open a bug report.
Previous Topic:Preferences between workspaces
Next Topic:Eclipse 2019-12R
Goto Forum:

Current Time: Wed Dec 02 13:28:58 GMT 2020

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

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

Back to the top