Modular JUnit (5.5.x) support
See original GitHub issueJUnit 5 uses explicit modules introduced by https://github.com/junit-team/junit5/commit/02417272bb22b8c710a0f58bc98505a49ef82107 since 5.5.x.
This modules seems to be incompatible with that since upgrading JUnit to 5.5.1 (5.4.2 works) in test-project
makes ../gradlew build
fail with:
failed to execute tests
org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not complete execution for Gradle Test Executor 4.
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:63)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.stop(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:132)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.lang.IllegalAccessError: class org.junit.platform.launcher.core.LauncherFactory (in unnamed module @0x6358e614) cannot access class org.junit.platform.commons.util.Preconditions (in module org.junit.platform.commons) because module org.junit.platform.commons does not export org.junit.platform.commons.util to unnamed module @0x6358e614
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:83)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:67)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:100)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:82)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:78)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
... 25 more
junit-platform-commons
seems to be loaded as unnamed module.
Is there something wrong with junit-platform-commons
or can this be fixed by this plugin?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
JUnit 5 User Guide
To find out what features are available in JUnit 5 and how to use them, read the corresponding sections of this User Guide,...
Read more >[SKARA-69] Upgrade to JUnit 5.5.x fails - Java Bug System
Upgrading to JUnit Jupiter 5.5.x (and therefore using Platform 1.5.x) via: ... \module\src\main\java\org\openjdk\skara\gradle\module\ModulePlugin.java}} ...
Read more >JUnit 5 Maven Dependency - HowToDoInJava
Learn to configure JUnit 5 with Maven, different JUnit modules and how to use ... junit-platform-suite : The @Suite support provided by this...
Read more >java.lang.NoClassDefFoundError: org/junit/platform/commons ...
As others suggested, using JUnit 5.5.2 version is the way to go here. ... Optional: Supports running Junit4 along with Junit5 ...
Read more >Validating and testing modules - Puppet
Puppet Development Kit (PDK) provides tools to help you run unit tests on your module and validate your module's metadata, syntax, and style....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Place all modules on project’s test module path like done with
org.junit.platform.launcher
here: https://github.com/openjdk/skara/pull/66Yes, Gradle will configure the Launcher also to be on the class-path, but it seems to work and is best solution I know as of today.
@sormuras FYI.
Analyzing Gradle’s debug logs, it seems like Gradle adds a set of non-modularized bundled
junit-platform-*
dependencies to the Test Worker classpath which results in the aforementioned error.00:02:23.400 [DEBUG] [org.gradle.process.internal.worker.DefaultWorkerProcessBuilder] Using implementation classpath [ ...omitted... file:<omitted>/gradle-5.5.1/lib/plugins/gradle-testing-base-5.5.1.jar, file:<omitted>/gradle-5.5.1/lib/plugins/gradle-testing-jvm-5.5.1.jar, file:<omitted>/gradle-5.5.1/lib/plugins/gradle-testing-junit-platform-5.5.1.jar, file:<omitted>/gradle-5.5.1/lib/plugins/junit-platform-engine-1.3.1.jar, file:<omitted>/gradle-5.5.1/lib/plugins/junit-platform-launcher-1.3.1.jar, file:<omitted>/gradle-5.5.1/lib/plugins/junit-platform-commons-1.3.1.jar, file:<omitted>/gradle-5.5.1/lib/plugins/junit-4.12.jar]
Whereas the worker also defines the
junit-platform-*
dependencies using the module path.00:02:23.405 [INFO] [org.gradle.process.internal.DefaultExecHandle] Starting process 'Gradle Test Executor 4'. Working directory: <omitted> Command: <omitted>zulu12.1.3-ca-jdk12-win_i686\bin\java.exe -Dorg.gradle.native=false --module-path <omitted>.gradle\caches\modules-2\files-2.1\org.junit.jupiter\junit-jupiter-engine\5.5.1\5e6fdb03ccfc853aca39704c5e97850d732df204\junit-jupiter-engine-5.5.1.jar;<omitted>.gradle\caches\modules-2\files-2.1\org.junit.jupiter\junit-jupiter-api\5.5.1\fc466b57ceda453119bd630c830ec68b93bba7f4\junit-jupiter-api-5.5.1.jar;<omitted>.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-engine\1.5.1\ab7d21edb0b176698a8252374fbed4f665519cdd\junit-platform-engine-1.5.1.jar;<omitted>.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-commons\1.5.1\d94bdac345742fe1b0d993f0be51bb7146579b1b\junit-platform-commons-1.5.1.jar;<omitted>.gradle\caches\modules-2\files-2.1\org.apiguardian\apiguardian-api\1.1.0\fc9dff4bb36d627bdc553de77e1f17efd790876c\apiguardian-api-1.1.0.jar;<omitted>.gradle\caches\modules-2\files-2.1\org.opentest4j\opentest4j\1.2.0\28c11eb91f9b6d8e200631d46e20a7f407f2a046\opentest4j-1.2.0.jar --patch-module recipe.services.impl=<omitted>recipe-services\build\classes\java\test;<omitted>recipe-services\build\resources\main;<omitted>recipe-services\build\resources\test --add-modules ALL-MODULE-PATH --add-reads recipe.services.impl=org.junit.jupiter.api --add-opens recipe.services.impl/com.epm.recipe.service.impl=org.junit.platform.commons @<omitted>AppData\Local\Temp\gradle-worker-classpath5430840299279566543txt -Xmx512m -Dfile.encoding=windows-1252 -Duser.country=US -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 4'
Not sure if this could be workarounded by this plugin.