Enable Cucumber support
To be able to use Cucumber in your application, make sure that the necessary plugins are enabled and add the Cucumber library to your project.
Enable plugins
In IntelliJ Ultimate, the required plugins are bundled and enabled by default. However, we recommend you to make sure that they are switched on.
In IntelliJ Community, the necessary plugins are not bundled, that is why you need to install and enable them.
Press Ctrl+Alt+S to open the IDE settings and then select
.Switch to the Installed tab and make sure that the following plugins are enabled (the plugins must be enabled in the specified order):
Gherkin
Cucumber for Java
Cucumber for Groovy (optional: install this plugin if you want to create step definitions in Groovy)
If the plugins are not installed, switch to the Marketplace tab, type their names in the search field in the specified order, and click Install next to each of them.
Apply the changes and close the dialog. Restart the IDE if prompted.
Add the Cucumber library
Follow these steps to add a library if you're building your project with the native IntelliJ IDEA builder:
In the main menu, go to
(Ctrl+Alt+Shift+S).Under Project Settings, select Libraries and click .
In the dialog that opens, specify the artifact of the library version that you want to use in your project, for example:
io.cucumber:cucumber-java:jar:6.1.1
orio.cucumber:cucumber-java8:jar:6.1.1
(if you want to use lambda expressions in step definitions).Click OK.
Apply the changes and close the dialog.
Follow these steps if you're using Maven in your project:
In your pom.xml, add the following dependencies (make sure to specify the latest version of Cucumber):
<dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java</artifactId> <version>6.1.1</version> <scope>test</scope> </dependency>Alternatively, if you want to use lambda expressions in step definitions, add:
<dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java8</artifactId> <version>6.1.1</version> <scope>test</scope> </dependency>Press Ctrl+Shift+O or click in the Maven tool window to import the changes.
For more information about working with Maven, refer to Maven dependencies.
Use these steps if you're building your project with Gradle.
Open your build.gradle and add the following dependencies (make sure to specify the latest version of Cucumber):
For Gradle 5 and later, add:
dependencies { testImplementation 'io.cucumber:cucumber-java:6.1.1' }Alternatively, if you want to use lambda expressions in step definitions, add:
dependencies { testImplementation 'io.cucumber:cucumber-java8:6.1.1' }For Gradle 4.10.3 and earlier, add:
dependencies { testCompile 'io.cucumber:cucumber-java:6.1.1' }Alternatively, if you want to use lambda expressions in step definitions, add:
dependencies { testCompile 'io.cucumber:cucumber-java8:6.1.1' }To find out your Gradle version, run
./gradlew --version
in the Terminal (Alt+F12).When the dependencies are added to your build.gradle, press Ctrl+Shift+O or click in the Gradle tool window to import the changes.
Prepare folder structure
Make sure that your project has the following folders:
Test Sources Root: a folder that stores your test code
Test Resources Root: a folder that stores files associated with your test sources