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 #1816461] Tue, 29 October 2019 16:24 Go to next message
Frank Heister is currently offline Frank HeisterFriend
Messages: 2
Registered: October 2019
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:
 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

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,

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 #1824041 is a reply to message #1816461] Mon, 06 April 2020 23:12 Go to previous message
krishnananda mohanty is currently offline krishnananda mohantyFriend
Messages: 1
Registered: April 2020
Junior Member
I am too getting the same error every time with one my projects.
Previous Topic:lost main class
Next Topic:The import java.util.Arrays cannot be resolved
Goto Forum:

Current Time: Sun Nov 29 14:51:22 GMT 2020

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

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

Back to the top