https://github.com/cucumber/cucumber-jvm-starter-gradle-java
This is the simplest possible setup for Cucumber-JVM using Java with Gradle.
https://github.com/cucumber/cucumber-jvm-starter-gradle-java
Last synced: 6 months ago
JSON representation
This is the simplest possible setup for Cucumber-JVM using Java with Gradle.
- Host: GitHub
- URL: https://github.com/cucumber/cucumber-jvm-starter-gradle-java
- Owner: cucumber
- License: mit
- Created: 2025-12-06T19:23:37.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2026-01-17T10:36:04.000Z (6 months ago)
- Last Synced: 2026-01-17T22:05:20.974Z (6 months ago)
- Language: Java
- Size: 1.27 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cucumber-JVM Starter: Java with Gradle
This is the simplest possible setup for Cucumber using Java with Gralde.
There is nothing fancy like a webapp or browser testing. All this does is to
show you how to set up and run Cucumber!
There is a single feature file with one scenario. The scenario has three steps,
one passing, skipped and undefined. See if you can make them all pass!
To write assertions the project comes with [AssertJ](https://assertj.github.io/doc/#assertj-core-assertions-guide)
included.
## Get the code
Git:
git clone https://github.com/cucumber/cucumber-jvm-starter-gradle-java.git
cd cucumber-jvm-starter-gradle-java
Or [download a zip](https://github.com/cucumber/cucumber-jvm-starter-gradle-java/archive/main.zip) file.
## Run the tests
Open a command window and run:
./gradlew test --rerun-tasks --info
This runs Cucumber features using Cucumber's JUnit Platform Engine. The `Suite`
annotation on the `RunCucumberTest` class tells JUnit to kick off Cucumber.
## Configuration
The [Cucumber JUnit Platform Engine](https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-junit-platform-engine) uses configuration parameters to know what features to run,
where the glue code lives, what plugins to use, etc. When using JUnit, these
configuration parameters are provided through the `@ConfigurationParameter`
annotation on your test.
For available parameters see: `io.cucumber.junit.platform.engine.Constants`
## Run a subset of Features or Scenarios
Specify a particular scenario by *line*
@SelectClasspathResource(value = "io/cucumber/skeleton/belly.feature", line = 3)
In case you have multiple feature files or scenarios to run against repeat the
annotation.
You can also specify what to run by *tag*.
First add a tag to a scenario:
```feature
Feature: Belly
@Zucchini
Scenario: a few cukes
```
Then add an annotation to `RunCucumberTest`.
```java
@IncludeTags("Zucchini")
```
These take a
[JUnit5 Tag Expression](https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions).
Note: When using JUnit, the `@` is not part of the tag.
Tags can also be selected from the CLI using the `cucumber.filter.tags` parameter.
This takes a [Cucumber Expression](https://github.com/cucumber/cucumber-expressions).
```
./gradlew test --rerun-tasks --info -Dcucumber.filter.tags="not @Haricots and (@Zucchini or @Gherkin)"
```
Note: Add `-Dcucumber.plugin=pretty` to get a more detailed output during test execution.
### Running a single scenario or feature
Gradle does not (yet) support selecting single features or scenarios
with JUnit selectors. As a work around the `cucumber.features` property can be
used. Because this property will cause Cucumber to ignore any other selectors
from JUnit it is prudent to only execute the Cucumber engine.
To select the scenario on line 3 of the `belly.feature` file use:
```
./gradlew test --rerun-tasks --info -Dcucumber.features=src/test/resources/io/cucumber/skeleton/belly.feature:3 -Dcucumber.plugin=pretty
```
Note: Add `-Dcucumber.plugin=pretty` to get a more detailed output during test execution.