jqwik-team / jqwik

Property-Based Testing on the JUnit Platform
http://jqwik.net
Eclipse Public License 2.0
576 stars 64 forks source link

TestEngine with ID 'jqwik' failed to discover tests [BUG] #584

Closed mstepan closed 3 months ago

mstepan commented 3 months ago

Bug Description

jqwik simple test failed with junit 5.

Aug 09, 2024 9:56:40 AM org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'jqwik' failed to discover tests
java.lang.NoSuchMethodError: 'org.junit.platform.engine.EngineDiscoveryListener org.junit.platform.engine.EngineDiscoveryRequest.getDiscoveryListener()'
    at net.jqwik.engine.discovery.JqwikDiscoverer.discover(JqwikDiscoverer.java:32)
    at net.jqwik.engine.JqwikTestEngine.discover(JqwikTestEngine.java:41)
    at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:177)
    at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:164)
    at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:120)
    at org.apache.maven.surefire.junitplatform.TestPlanScannerFilter.accept(TestPlanScannerFilter.java:56)
    at org.apache.maven.surefire.util.DefaultScanResult.applyFilter(DefaultScanResult.java:102)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.scanClasspath(JUnitPlatformProvider.java:146)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:127)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:377)
    at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:138)
    at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:465)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:451)

jqwik version: 1.9.0 java: 17 junit: 5.5.2

test:

public class MathTest {

    @Property
    void absAlwaysPositive(@ForAll int value) {
        assertTrue(Math.abs(value) >= 0);
    }
}
jlink commented 3 months ago

@mstepan Thanks for posting.

There seems to be some version conflict happening. Can you post your Gradle or POM file?

First guess: jqwik 1.9.0 is made with JUnit platform 1.10.x (so it pairs with Jupiter 5.10.x). I don't do backwards compatibility testing below JUnit's minor version (5.10.0).

jlink commented 3 months ago

On further research: Starting with jqwik 1.8.0 (released in September 2023), JUnit 1.10 is the minimum required platform version.

jlink commented 3 months ago

It might work with JUnit 1.6.x, but that's just guessing.

mstepan commented 3 months ago

I can confirm that with junit 5.10.x it's working.