Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with JUnit5 5.10.0-M1 #94

Closed
davidburstrom opened this issue May 18, 2023 · 4 comments
Closed

Incompatibility with JUnit5 5.10.0-M1 #94

davidburstrom opened this issue May 18, 2023 · 4 comments

Comments

@davidburstrom
Copy link
Contributor

Using pitest-junit5-plugin version 1.1.2 and JUnit 5 version 5.10.0-M1, test discovery fails with the attached stacktrace. It works if JUnit 5 version 5.9.2 is used. Seems like a shading issue.

org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests
        at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160)
        at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:132)
        at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:107)
        at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:78)
        at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
        at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
        at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
        at org.pitest.junit5.JUnit5TestUnitFinder.findTestUnits(JUnit5TestUnitFinder.java:83)
        at org.pitest.mutationtest.config.PrioritisingTestUnitFinder.findTestUnits(PrioritisingTestUnitFinder.java:20)
        at org.pitest.testapi.execute.FindTestUnits.findTestUnits(FindTestUnits.java:64)
        at org.pitest.testapi.execute.FindTestUnits.getTestUnits(FindTestUnits.java:47)
        at org.pitest.testapi.execute.FindTestUnits.findTestUnitsForAllSuppliedClasses(FindTestUnits.java:36)
        at org.pitest.coverage.execute.CoverageMinion.discoverTests(CoverageMinion.java:177)
        at org.pitest.coverage.execute.CoverageMinion.getTestsFromParent(CoverageMinion.java:163)
        at org.pitest.coverage.execute.CoverageMinion.main(CoverageMinion.java:87)
Caused by: org.junit.platform.commons.JUnitException: ClassSelector [className = 'io.github.davidburstrom.gradle.versioncompatibility.VersionCompatibilityPluginTest'] resolution failed
        at org.junit.platform.launcher.listeners.discovery.AbortOnFailureLauncherDiscoveryListener.selectorProcessed(AbortOnFailureLauncherDiscoveryListener.java:39)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:103)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:83)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:113)
        at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:46)
        at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:69)
        at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152)
        ... 15 more
Caused by: java.lang.NoSuchMethodError: 'java.util.stream.Stream org.junit.platform.commons.support.ReflectionSupport.streamNestedClasses(java.lang.Class, java.util.function.Predicate)'
        at org.junit.jupiter.engine.discovery.ClassSelectorResolver.lambda$toResolution$12(ClassSelectorResolver.java:138)
        at org.junit.platform.engine.support.discovery.SelectorResolver$Match.expand(SelectorResolver.java:667)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$enqueueAdditionalSelectors$1(EngineDiscoveryRequestResolution.java:110)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
        at java.base/java.util.Collections$2.tryAdvance(Collections.java:4747)
        at java.base/java.util.Collections$2.forEachRemaining(Collections.java:4755)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.enqueueAdditionalSelectors(EngineDiscoveryRequestResolution.java:109)
        at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:95)
        ... 20 more
@nagkumar
Copy link

hcoles/pitest#1210

@hcoles
Copy link
Contributor

hcoles commented May 18, 2023

This isn't quite as straightforward as "a shading issue". There's a discussion of the problem here

hcoles/pitest#1209

And a fix for maven users here

hcoles/pitest#1212

I'll release this and a new version of the junit-5-plugin shortly. Gradle users will need to manually add platform-launcher to their test classpath until a fix similar to the maven soloution can be added to the gradle plugin.

@hcoles
Copy link
Contributor

hcoles commented May 19, 2023

This is fixed by the combination of 1.2.0 of the junit5 plugin and pitest 1.14.0.

If you are using gradle, you will need to also ensure that junit-platform-launcher v 1.10.0-M1 is included on the test runtime classpath.

@nagkumar
Copy link

wow.. tested it works now.. with all the changes..

curious in 5.9.2 this dependency was not needed now with 10.x this is needed

testRuntimeOnly("org.junit.platform:junit-platform-launcher")

what changes in 10.x made such explicit need as my junit test cases work even without this dependency even on 10.x but not pitest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants