Cucumber-JVM
Cucumber-JVM is published in the central Maven repository. You can install it by adding dependencies to your project.
Make sure the Cucumber version is the same for all Cucumber dependencies.
Maven
Add the following dependency to your pom.xml
:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.22.2</version>
<scope>test</scope>
</dependency>
You can now run Cucumber from the command line or run Cucumber with Maven.
Gradle
If you are using Gradle 4.10.3 or older add the following dependencies to build.gradle
:
dependencies {
testCompile 'io.cucumber:cucumber-java:7.22.2'
testCompile 'io.cucumber:cucumber-junit:7.22.2'
}
repositories {
mavenCentral()
}
Similarly, if you want to use Gradle 5.0 or more recent add the following dependencies to build.gradle
or build.gradle.kts
:
dependencies {
testImplementation("io.cucumber:cucumber-java:7.22.2")
testImplementation("io.cucumber:cucumber-junit:7.22.2")
}
repositories {
mavenCentral()
}
You can now run Cucumber from the command line to execute by adding a cucumber task to build.gradle
or build.gradle.kts
.
JUnit 5 integration
It is also possible to use cucumber-junit-platform-engine to run your Cucumber test suite.
JUnit 4 integration
It is also possible to use cucumber-junit to run your Cucumber test suite.
Assertions
Cucumber does not come with an assertion library. Instead, use the assertion methods from a unit testing tool.
Dependency Injection
While it's not required, we strongly recommend you include one of the dependency injection modules as well. This allows you to share state between step definitions without resorting to static variables (a common source of flickering scenarios).