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.34.3</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.34.3'
testCompile 'io.cucumber:cucumber-junit:7.34.3'
}
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.34.3")
testImplementation("io.cucumber:cucumber-junit:7.34.3")
}
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).