I'm using Cucumber and JUnit5 to write tests for my projects. My project uses Spring Framework and Gradle as a build tool and I use IntelliJ Idea as an editor which has Cucumber and Gradle plugins. Here is my Cucumber's runner:
package com.mycom.myproject.cucumber;
import static io.cucumber.junit.platform.engine.Constants.*;
import org.junit.platform.suite.api.*;
@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("src/test/resources")
@ConfigurationParameters({
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.mycom.myproject.cucumber.steps"),
@ConfigurationParameter(key = FEATURES_PROPERTY_NAME, value = "src/test/resources/cucumber"),
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "html")
})
public class RunCucumberTest {
}
This is my cucumberBootstrap class:
package com.mycom.myproject.cucumber;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import com.mycom.myproject.Application;
import io.cucumber.spring.CucumberContextConfiguration;
@CucumberContextConfiguration
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, args = "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration,com.arkea.catalyst.kafka.spring.KafkaAutoConfiguration")
@ActiveProfiles({ "IC" })
public class CucumberBootstrap {
}
My steps definition class:
package com.mycom.myproject.cucumber.steps;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class StepDefinition extends CucumberBootstrap {
@Quand("I want to calculate my bill")
public void iWantToCalculateMyBill() {
// some code
}
@Alors("I have this result")
public void iHaveThisResult() {
// some assertions
}
}
Here is my gradle.build file:
// Tests dependencies
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testImplementation 'org.junit.jupiter:junit-jupiter-engine'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'io.rest-assured:rest-assured:4.1.2'
testImplementation "io.cucumber:cucumber-java:$cucumberVersion"
testImplementation "io.cucumber:cucumber-spring:$cucumberVersion"
testImplementation "io.cucumber:cucumber-junit-platform-engine:$cucumberVersion"
testImplementation "org.junit.vintage:junit-vintage-engine"
testImplementation 'org.junit.platform:junit-platform-suite:1.9.0'
implementation 'org.junit.platform:junit-platform-commons:1.9.0'
}
test {
useJUnitPlatform()
systemProperty 'java.util.logging.manager', 'org.apache.logging.log4j.jul.LogManager'
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
}
My cucumber's version is 7.5.0. No matter how I change the code, I keep having the "no tests found for given includes" error and I have no idea how to change it. Do you guys have any clue?
Thanks