After the upgrade to version 7.23
of io.cucumber:cucumber-bom
I'm getting
Unable to load class 'org.junit.platform.engine.support.discovery.DiscoveryIssueReporter'.
when trying to run my tests.
I checked the setup which cucumber team recommends but unfortunately they don't include spring boot.
I tried getting further information by running ./gradlew -q dependencyInsight --dependency org.junit.platform:junit-platform-engine --configuration testRuntimeClasspath
and saw
org.junit.platform:junit-platform-engine:1.12.2
+--- org.junit.jupiter:junit-jupiter-engine:5.12.2
| +--- org.junit.jupiter:junit-jupiter:5.12.2
| | +--- org.springframework.boot:spring-boot-starter-test:3.5.4
while
org.junit.platform:junit-platform-engine:1.13.3 -> 1.12.2
\--- io.cucumber:cucumber-junit-platform-engine:7.24.0
+--- testRuntimeClasspath (requested io.cucumber:cucumber-junit-platform-engine)
\--- io.cucumber:cucumber-bom:7.24.0
\--- testRuntimeClasspath
So I wonder how you should change the dependencies laid out in your build.gradle.kts
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation(platform(libs.cucumber.bom))
testImplementation("io.cucumber:cucumber-java")
testImplementation("io.cucumber:cucumber-junit-platform-engine")
testImplementation("org.junit.platform:junit-platform-suite")
testImplementation("io.cucumber:cucumber-spring")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
when the version chosen for the cucumber-bom
is higher than 7.23
.
As stated above I tried getting more insights into the dependencies and therefore found out where the older junit platform engine comes from (spring boot starter test). I thought I wasn't the only one using the combination of cucumber and spring boot so I expected it to be possible to align them in a robust way.
EDIT: I forgot to mention I'm using
plugins {
id("org.springframework.boot") version "3.5.4"
id("io.spring.dependency-management") version "1.1.7"
id("java-library")
}
This perhaps changes how the resolution is managed.
Cucumber ≥ 7.23 needs JUnit Platform 1.13.x, but Spring Boot 3.5.4’s spring-boot-starter-test
brings 1.12.2, causing DiscoveryIssueReporter
to be missing.
1. You can force version by forcing version in build.gradle.kts
configurations.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.junit.platform") {
useVersion("1.13.3")
}
}
}
2. Or use JUnit bom before importing spring-boot-starter-test
testImplementation(platform("org.junit:junit-bom:5.10.3"))
testImplementation(platform("org.junit.platform:junit-platform-bom:1.13.3"))