Create step definitions
In Cucumber, step definitions should be stored in a named package under Test Sources Root. Keeping definitions in the default package might result in an error as IntelliJ IDEA will not be able to locate them.
Create a package for step definitions
Right-click Test Sources Root in the Project tool window and select .
Give the package a meaningful name and press Enter .
Add step definitions
If a .feature file refers to a non-existent step, IntelliJ IDEA recognizes and highlights such a step, and provides an intention action that helps create the missing step definition.
Place the caret at a step in your .feature file and press Alt+Enter .
The list of suggested intention actions opens.
Select Create step definition to create a definition only for one step, or select Create all step definitions to add definitions for all steps in a scenario.
If you already have definition files in your project, the IDE prompts you select to which file you want to add the new step definitions. You can select one of the existing files or create a new one.
If you opt to create a new step definition file, a dialog opens. Name the new file, select the type (Java, Java 8, or Groovy) and specify its location.
Note that files with step definitions should be located in a dedicated package. Keeping them in the default package might result in an error.
In the selected step definition file that opens in the editor, enter the desired code.
Note the following: