pitest-junit5-plugin icon indicating copy to clipboard operation
pitest-junit5-plugin copied to clipboard

Plugin crashes when `junit-jupiter-engine` dependency is not explicitly declared

Open Stephan202 opened this issue 1 year ago • 1 comments

After merging PicnicSupermarket/error-prone-support#973, in which explicit test dependencies on junit-jupiter-engine were dropped (since Surefire anyway provides the test framework implementation based on an analysis of the test classpath), we noticed that Pitest started failing. See PicnicSupermarket/error-prone-support#972 for an example. Reported output:

[ERROR] Failed to execute goal org.pitest:pitest-maven:1.15.3:mutationCoverage (default-cli) on project documentation-support: Execution default-cli of goal org.pitest:pitest-maven:1.15.3:mutationCoverage failed: Coverage generation minion exited abnormally! (UNKNOWN_ERROR)
[ERROR] 
[ERROR] Please copy and paste the information and the complete stacktrace below when reporting an issue
[ERROR] VM : OpenJDK 64-Bit Server VM
[ERROR] Vendor : Eclipse Adoptium
[ERROR] Version : 17.0.9+9
[ERROR] Uptime : 3318
[ERROR] Input -> 
[ERROR]  1 : -XX:ReservedCodeCacheSize=512m
[ERROR]  2 : -XX:SoftRefLRUPolicyMSPerMB=10
[ERROR]  3 : -XX:+UseParallelGC
[ERROR]  4 : --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
[ERROR]  5 : --add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
[ERROR]  6 : --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
[ERROR]  7 : --add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
[ERROR]  8 : --add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
[ERROR]  9 : --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
[ERROR]  10 : --add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
[ERROR]  11 : --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
[ERROR]  12 : --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
[ERROR]  13 : --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
[ERROR]  14 : -Dclassworlds.conf=/home/user/.sdkman/candidates/maven/current/bin/m2.conf
[ERROR]  15 : -Dmaven.home=/home/user/.sdkman/candidates/maven/current
[ERROR]  16 : -Dlibrary.jansi.path=/home/user/.sdkman/candidates/maven/current/lib/jansi-native
[ERROR]  17 : -Dmaven.multiModuleProjectDirectory=/path/to/error-prone-support
[ERROR] BootClassPathSupported : false

In our case the cause was not so hard to determine, but it could be a real head-scratcher if this issue happens when a user introduces Pitest for the first time. So the question is: can the plugin be updated to mirror whatever Surefire does?

Stephan202 avatar Jan 13 '24 21:01 Stephan202

This is likely fixed in 1.2.2 which fixes an issue where platform-launcher was accidentally included as a transitive dependency.

hcoles avatar Feb 24 '25 09:02 hcoles

I just tested with version 1.2.3, but the issue persists. To test:

  1. Check out this branch.
  2. Execute ./run-mutation-tests.sh.

Stephan202 avatar Aug 20 '25 11:08 Stephan202

@Stephan202 This should be fixed for maven users by

https://github.com/hcoles/pitest/pull/1426

A similar change will be required in the gradle plugin.

hcoles avatar Sep 15 '25 14:09 hcoles

Fix for maven released in pitest 1.20.3

hcoles avatar Sep 15 '25 15:09 hcoles

I can confirm that 1.20.3 fixes the problem. A relief after having spent a few hours trying to stepping through the code looking for the cause of

9:33:14 PM PIT >> INFO : Sent tests to minion
9:33:14 PM PIT >> FINE : MINION : java.lang.NoClassDefFoundError: org/junit/platform/engine/ConfigurationParameters
9:33:14 PM PIT >> FINE : MINION : 	at org.pitest.junit5.JUnit5TestUnitFinder.<init>(JUnit5TestUnitFinder.java:60)
9:33:14 PM PIT >> FINE : MINION : 	at org.pitest.junit5.JUnit5Configuration.testUnitFinder(JUnit5Configuration.java:43)
9:33:14 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
9:33:14 PM PIT >> FINE : MINION : 	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
9:33:14 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
9:33:14 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
9:33:14 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
9:33:14 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
9:33:14 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
9:33:14 PM PIT >> FINE : MINION : 	at org.pitest.mutationtest.config.PrioritisingTestConfiguration.makeFinder(PrioritisingTestConfiguration.java:61)
9:33:14 PM PIT >> FINE : MINION : 	at org.pitest.mutationtest.config.PrioritisingTestConfiguration.<init>(PrioritisingTestConfiguration.java:20)
9:33:14 PM PIT >> FINE : MINION : 	at org.pitest.mutationtest.config.MinionSettings.getTestFrameworkPlugin(MinionSettings.java:57)
9:33:14 PM PIT >> FINE : MINION : 	at org.pitest.coverage.execute.CoverageMinion.createTestPlugin(CoverageMinion.java:181)
9:33:14 PM PIT >> FINE : MINION : 	at org.pitest.coverage.execute.CoverageMinion.getTestsFromParent(CoverageMinion.java:151)
9:33:14 PM PIT >> FINE : MINION : 	at org.pitest.coverage.execute.CoverageMinion.main(CoverageMinion.java:82)
9:33:14 PM PIT >> FINE : MINION : Caused by: java.lang.ClassNotFoundException: org.junit.platform.engine.ConfigurationParameters
9:33:14 PM PIT >> FINE : MINION : 	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
9:33:14 PM PIT >> FINE : MINION : 	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
9:33:14 PM PIT >> FINE : MINION : 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
9:33:14 PM PIT >> FINE : MINION : 	... 15 more
9:33:14 PM PIT >> SEVERE : Coverage generator Minion exited abnormally due to UNKNOWN_ERROR

and

:35:36 PM PIT >> FINE : MINION : org.junit.platform.commons.PreconditionViolationException: Cannot create Launcher without at least one TestEngine; consider adding an engine implementation JAR to the classpath
9:35:36 PM PIT >> FINE : MINION : 	at org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:314)
9:35:36 PM PIT >> FINE : MINION : 	at org.junit.platform.launcher.core.DefaultLauncher.<init>(DefaultLauncher.java:55)
9:35:36 PM PIT >> FINE : MINION : 	at org.junit.platform.launcher.core.LauncherFactory.createDefaultLauncher(LauncherFactory.java:134)
9:35:36 PM PIT >> FINE : MINION : 	at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:125)
9:35:36 PM PIT >> FINE : MINION : 	at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:109)
9:35:36 PM PIT >> FINE : MINION : 	at org.pitest.junit5.JUnit5TestUnitFinder.<init>(JUnit5TestUnitFinder.java:60)
9:35:36 PM PIT >> FINE : MINION : 	at org.pitest.junit5.JUnit5Configuration.testUnitFinder(JUnit5Configuration.java:43)
9:35:36 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
9:35:36 PM PIT >> FINE : MINION : 	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
9:35:36 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
9:35:36 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
9:35:36 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
9:35:36 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
9:35:36 PM PIT >> FINE : MINION : 	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
9:35:36 PM PIT >> FINE : MINION : 	at org.pitest.mutationtest.config.PrioritisingTestConfiguration.makeFinder(PrioritisingTestConfiguration.java:61)
9:35:36 PM PIT >> FINE : MINION : 	at org.pitest.mutationtest.config.PrioritisingTestConfiguration.<init>(PrioritisingTestConfiguration.java:20)
9:35:36 PM PIT >> FINE : MINION : 	at org.pitest.mutationtest.config.MinionSettings.getTestFrameworkPlugin(MinionSettings.java:57)
9:35:36 PM PIT >> FINE : MINION : 	at org.pitest.coverage.execute.CoverageMinion.createTestPlugin(CoverageMinion.java:181)
9:35:36 PM PIT >> FINE : MINION : 	at org.pitest.coverage.execute.CoverageMinion.getTestsFromParent(CoverageMinion.java:151)
9:35:36 PM PIT >> FINE : MINION : 	at org.pitest.coverage.execute.CoverageMinion.main(CoverageMinion.java:82)

computerlove avatar Sep 16 '25 19:09 computerlove