Gradle runs no Cucumber scenarios from my feature files
gradle test finishes successfully but no Cucumber scenarios are listedShort answer
Cucumber runs on the JUnit Platform, so Gradle must call useJUnitPlatform() and have the cucumber-junit-platform-engine on the test classpath. Also check that Gradle can see the feature directory, that cucumber.features is not overriding your selectors, and that the test task is not skipped as up to date.
Fix it fast
1Find out which cause you have
Force the test task to run again and read its output. This separates a skipped task from one that really finds nothing.
./gradlew test --rerun2Match what you see, then jump to its fix
- 1
The task finishes with no Cucumber output at allThe test task does not use JUnit Platform, or has no Cucumber engineFix - 2
Engine is present, but resource-based tests are never foundGradle is not pointed at the feature filesFix - 3
A suite class with @SelectPackages runs nothing, and cucumber.features is set in properties or the command linecucumber.features overrides every other selectorFix - 4
The console shows the test task as UP-TO-DATEGradle skipped the test task as up to dateFix
- 1
What does the error look like?
gradle test finishes successfully but no Cucumber scenarios are listedFeature files exist under src/test but nothing runs
Cause 1 of 4
The test task does not use JUnit Platform, or has no Cucumber engine
1Check
Cucumber discovery is done by the cucumber engine. The README says to add cucumber-junit-platform-engine (and junit-platform-suite for suites) and, for Gradle, to enable useJUnitPlatform().
./gradlew dependencies --configuration testRuntimeClasspath | grep -i cucumber2Fix
Add the engine and select the platform. Take the version from the Cucumber BOM.
// build.gradle.kts
dependencies {
testImplementation("io.cucumber:cucumber-junit-platform-engine")
}
tasks.named<Test>("test") {
useJUnitPlatform()
}3Verify
Run the tests; scenarios should now be listed.
./gradlew test --rerunConfirmed by github.com
Cause 2 of 4
Gradle is not pointed at the feature files
1Check
Gradle supports resource-based tests, and the README points the test task at the directory holding the .feature files.
find . -name "*.feature" -not -path "*/build/*"2Fix
Declare the feature directory on the test task.
tasks.named<Test>("test") {
useJUnitPlatform()
testDefinitionDirs.from("src/test/features")
}3Verify
Run again and check the report.
./gradlew test --rerunConfirmed by github.com
Cause 3 of 4
cucumber.features overrides every other selector
1Check
The README warns that setting cucumber.features makes Cucumber ignore other selectors, such as those on a suite class.
grep -rn "cucumber.features" src/ build.gradle* gradle.properties2Fix
Remove the property, or put the right path in it deliberately. Remember that cucumber.glue takes comma separated package names.
# src/test/resources/cucumber.properties
cucumber.glue=com.example3Verify
Run the suite again.
./gradlew test --rerunConfirmed by github.com
Cause 4 of 4
Gradle skipped the test task as up to date
1Check
Gradle does not rerun tests whose inputs did not change.
./gradlew test2Fix
Force a rerun.
./gradlew test --rerun3Verify
The task shows as executed and prints results.
./gradlew test --rerunConfirmed by docs.gradle.org
How do I stop it coming back?
- Keep the feature files and the glue package in one documented place.
- Prefer cucumber.properties over scattered system properties.
- Run tests with --rerun after changing only feature files if results look stale.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
A Gradle build fails on classes that use Lombok annotations
Error: Annotation processors must be explicitly declared now.
Lombok is two things for Gradle: a compile-time library and an annotation processor.
3 causes, each with a fixBack end
Gradle 8 fails on Report destination: switch to outputLocation
What went wrong: 'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'
Gradle 8.0 removed the deprecated destination and enabled properties of the Report type.
2 causes, each with a fixBack end
IntelliJ IDEA compiles with a JDK that does not know Java 17
Invalid source release: 17
The compiler that IntelliJ or Gradle starts is older than Java 17, but the project asks for Java 17 source.
3 causes, each with a fixBack end
A scanner flags jackson-databind: how to upgrade it in Gradle
jackson-databind vulnerability reported by a dependency scanner
Find where the old jackson-databind comes from, then raise it.
3 causes, each with a fixBack end
Gradle cannot resolve spring-boot-gradle-plugin after a Spring Boot 3 upgrade
Plugin [id: 'org.springframework.boot', version: '3.0.1'] was not found in any of the following sources
Spring Boot 3 needs Java 17 or newer and a recent Gradle, and its Gradle plugin is published on the Gradle Plugin Portal.
3 causes, each with a fix