Skip to content

vinixnan/cucumber-junit5-gradle

Repository files navigation

Cucumber with JUnit5

This repository contains an example project that integrates Cucumber with JUnit5. It is the same setup explained in the blog post. In case you want to combine your examples/scenarios with Selenium check out cucumber-junit5-selenium-example.

Quick Start

$ 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.

Note that while this project uses the JUnit5 platform, it only requires the jupiter-api in order use JUnit 5 assertions. Replace this dependency in case you want to use another assertion library like AssertJ. If you are planning on running regular JUnit 5 tests along with your Cucumber examples/scenarios, add a dependency to jupiter-engine. The Gradle configuration is annotated to help you make changes for your own test setup, thus feel free to modify it!

cronn GmbH

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published