admin管理员组

文章数量:1392003

I have to start integration testing in a new springboot project and I'm struggle with Junit and Cucumber.

Java 23
Spring Boot 3.4.3
Gradle
Cucumber 7.20.1
Junit 5

I added these dependencies

    testRuntimeOnly '.junit.platform:junit-platform-launcher'

    // Add Cucumber dependencies
    testImplementation 'io.cucumber:cucumber-java:7.20.1'
    testImplementation "io.cucumber:cucumber-java:7.20.1"
    testImplementation "io.cucumber:cucumber-spring:7.20.1"
    testImplementation "io.cucumber:cucumber-junit-platform-engine:7.11.0"
    testImplementation '.junit.platform:junit-platform-suite:1.12.0'
    testImplementation '.junit.platform:junit-platform-engine:1.12.0'

I created a runner class

@Suite
@IncludeEngines("cucumber")
@SpringBootTest
@CucumberContextConfiguration
@SelectClasspathResource("features")
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example.democucumber")
public class RunAllCucumberTests {
}

And this is the structure of the project :

Project structure

When I run gradle, I have

.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not complete execution for Gradle Test Executor 6.
Caused by: .junit.platformmons.JUnitException: TestEngine with ID 'junit-platform-suite' failed to discover tests
Caused by: .junit.platformmons.JUnitException: TestEngine with ID 'cucumber' failed to discover tests

I can't get the runner to work, and I don't understand why the tests aren't being found. Does anyone have any idea, or perhaps a project skeleton with Spring 3 / Gradle / JUnit 5 / Cucumber, please?

本文标签: buildgradleSpringBoot 3Junit5CucumberJunit Runner don39t see cucumber testsStack Overflow