Cucumber School Logo

Watch the Cucumber School video lesson on installing Cucumber for JVM languages here.


Cucumber-JVM is published in the central Maven repository. You can install it by adding dependencies to your project.

Dependencies

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.20.1</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.20.1'
    testCompile 'io.cucumber:cucumber-junit:7.20.1'
}

repositories {
    mavenCentral()
}

Similarly, if you want to use Gradle 5.0 or more recent add the following dependencies to build.gradle:

dependencies {
    testImplementation 'io.cucumber:cucumber-java:7.20.1'
    testImplementation 'io.cucumber:cucumber-junit:7.20.1'
}

repositories {
    mavenCentral()
}

You can now run Cucumber from the command line to execute by adding a cucumber task to build.gradle.

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

You can help us improve this documentation. Edit this page.