I have my feature files
in src/resources/com/features
and my step definitions
in src/main/java/com/step_definitions
My tests all run correctly, but intelliJ refuses to see where the step defs are, even if I ask it to create a new one. Where is this configured?
inside the directory in which Cucumber is run is treated as a step definition. In the same directory, Cucumber will search for a Feature corresponding to that step definition. This is either the default case or the location specified with the relevant relevant relevant -r relevant option.
Add a Step Definition file 1) Create a new Class file in the 'stepDefinition' package and name it as 'Test_Steps', by right click on the Package and select New > Class. Do not check the option for 'public static void main' and click on Finish button. Take a look at the message in the console window.
From the main menu, select Run | Edit Configurations. or press Alt+Insert and select Cucumber Java from the list. After that, you can complete the configuration using the options on the right. For the description of each option, refer to Run/Debug configuration: Cucumber Java.
I was just tearing my hair out with exactly the same problem (for the record my background is Java, Ruby, Cucumber and RubyMine but I'm completely new to IntelliJ and Cucumber-JVM).
In the Cucumber-JVM run configuration
you must specify the package where the step definitions are stored in the glue
field as mentioned in the IntelliJ documentation. IntelliJ - for me at least - does not seem to provide a default value.
To elaborate further, a very basic project looks like this:
Example
└───src
├───main
│ └───java
└───test
├───java
│ └───com
│ └───bensnape
│ └───example
│ MyStepdefs.java
└───resources
example.feature
The glue
value here would be com.bensnape.example
.
After playing with IntelliJ some more this morning, it seems that it does provide the glue
value for you if you adhere to the Cucumber-JVM conventions - i.e. the features must live under src/test/resources/<package>
and similarly, the steps must live under src/test/java/<package>
.
Example project tree:
Example
└───src
├───main
│ └───java
└───test
├───java
│ └───com
│ └───bensnape
│ └───example
│ MyStepdefs.java
│
└───resources
└───com
└───bensnape
└───example
example.feature
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With