This repository contains an example project that integrates Cucumber with JUnit5. It is the same setup explained in the blog post.
$ git clone https://github.com/cronn/cucumber-junit5-example your-own-tests
$ cd your-own-tests
$ ./gradlew test
Gradle will execute all feature files which are located in the src/test/resources/features
folder as specified in RunAllCucumberTests. In order to filter execution to just a subset of all features, use the includeTags
property as in the following example. It uses JUnit5 tag expressions:
$ ./gradlew test --project-prop includeTags="first | awesome"
In order to ignore just a subset of features, use the includeTags
property like this:
$ ./gradlew test --project-prop includeTags="!second"
build.gradle.kts uses cucumber.execution.parallel.enabled
to enable parallel test execution by default. Additionally, it uses the cucumber.plugin
option to write a reports file to build/reports/cucumber.ndjson
, an execution timeline to build/reports/timeline
and an HTML report to build/reports/cucumber.html
. All Cucumber features/rules/examples/scenarios annotated with @disabled
are filtered by default and are not executed. This project declares an extra dependency to picocontainer in order to show dependency injection within tests - remove it in case you don't need it. The Gradle configuration is annotated to help you make changes for your own test setup, thus feel free to modify it!