mercredi 7 avril 2021

Can't run JUnit 5 tests on Eclipse 2021-03

I am working on a project that includes both Gradle and Maven subprojects. Until yesterday I was using Eclipse 2020-03, but I updated to 2021-03 and now I can't run any tests. I haven't changed anything to the project's configuration, junit 5.6.0 is included both in pom.xml and build.gradle.

Now whenever I try to run a test, I get this error:

java.lang.NoClassDefFoundError: org/junit/platform/commons/util/ClassNamePatternFilterUtils
at org.junit.platform.launcher.core.LauncherFactory.loadAndFilterTestExecutionListeners(LauncherFactory.java:122)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:108)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:75)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.<init>(JUnit5TestLoader.java:34)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.base/java.lang.Class.newInstance(Class.java:584)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:371)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:366)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:310)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:225)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.commons.util.ClassNamePatternFilterUtils
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 14 more

When I add Junit 5 manually to the project's build path, as suggested by a lot of similar questions here, I get this in the Add Library Window:

Current Location: org.junit.jupiter.api_5.7.1.v20210222-1948.jar - /Users/user/.p2/pool/plugins 

But even then, when I add it, I get that junit launcher was not found, followed by:

java.lang.SecurityException: class "org.junit.platform.commons.util.ClassNamePatternFilterUtils"'s signer information does not match signer information of other classes in the same package

Note that in 2020-03, the project's build path did not include explicitly Junit 5 (hadn't added it manually). The same tests also work there as intended, both in Maven and Gradle projects.

Then, I tried deleting all org.junit.jupiter jars from .p2/pool/plugins, this didn't work either.

Aucun commentaire:

Enregistrer un commentaire