Reputation: 3652
I'm trying to follow this article to match Cucumber specs with step definitions in IntelliJ.
When I press Alt+Enter, I see Inspection 'Undefined Step' options. However, I should see the intention action Create Step Definition.
I thought I had the Cucumber IntelliJ plugin installed, so that shouldn't be a problem. Any help is greatly appreciated.
Upvotes: 31
Views: 88078
Reputation: 1
The case for me was, Class is NOT defined as public ... i.e. The class where my step definitions are specified was not Public. Reason for removing Public modifier for class was -- I am using @Test from Junit5 and is recommending to remove Public for both class and methods.
Upvotes: 0
Reputation: 11
I had the same issue and was resolved by going to Run> Edit configuration> Before Launch then click on the add option "+" and add Build Project option. enter image description here
Upvotes: 1
Reputation: 138
If still not working, you can add runner class
add -> runner package -> Main Runner class
-test
-runner - Create this package
-stepPackage
-resources
-features
@CucumberOptions(features = {"classpath:features"}, glue = {"stepDefinition"},
monochrome = false,dryRun = false)
public class MainRunner extends AbstractTestNGCucumberTests {
}
That is it. Just run this class first. Right mouse click and Run'MainRunner'
Then it will work if you just go back and run Scenarios as well
Upvotes: 0
Reputation: 31
Me not help not one of suggestions above. But i find if you start one test from runner the problem goes on (it is worked if you have runner for some tests( Runner is class that have line @CucumberOptions( features = "src/test/resources/stability_*****_features/", glue = "steps" )
And may be the next line in config helped you^ in configurations i put line: --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm4SMFormatter in Programm arguments line - it help me
Upvotes: 0
Reputation: 31
Most probably you need to install the cucumber for java plugin, if already installed then you need to enable from File>>Settings>>pugins.
Upvotes: 3
Reputation: 187
The issue was fixed after updating the Intelij to the latest version and after updating the cucumber and gherkin intelij plugins
Upvotes: 0
Reputation: 31
I had the same issue where all of a sudden my feature to step definition glue was missing. All i did was goto Run->Edit Configurations->and removed the cucumber java configuration and restarted IntelliJ. it worked fine.
Upvotes: 3
Reputation: 113
For me there was a collision between Sidesteps plugin and Cucumber plugin in Intellij and as a result *.feature file extension was taken over by the Sidesteps plugin and was expecting Sidesteps step definitions ignoring Cucumber step definitions. No clue what Sidesteps actually is. So went to IntelliJ settings and reassigned the *.feature extension to Cucumber Scenario type and then everything worked fine and Cucumber steps are recognized by Intellij now.
Upvotes: 1
Reputation: 79
"Undefined" step error message would appear if you import a new BDD project.
This error could appear due to two reasons.
Solution: 1. If the plugin is not found then you need to install from the below location. File->Settings->Plugins->MarketPlace->Cucumber for Java 2. After Importing the project disable the plugin and enable once again in the Installed section under Installed.
Upvotes: 1
Reputation: 175
I found that even with the Cucumber for Java plugin installed it was still generating only one step. I eventually uninstalled the Cucumber for Java plugin and reinstalled it and all step definitions were generated.
Upvotes: 0
Reputation: 33963
I had to uncheck the "Create separate module per source set
" checkbox under the "Build, Execution, Deployment" -> "Build Tools" -> "Gradle"
settings, and then rebuild the project.
Upvotes: 2
Reputation: 4749
I wasted around an hour to solve this. My issue was, Idea was able to navigate from feature to step file. But when I wanted to execute one cucumber test from feature file (Right click and Run Scenario), it was giving error as undefined steps.
Solution: In the Edit Configuration -> provide the Glue for the cucumber which should be absolute path till steps folder. Please see below screen shot
This fixed my problem of running feature file from Idea. Hope this helps others.
Upvotes: 14
Reputation: 3652
Turns out I had the Gherkin plugin but not the Cucumber for Java plugin.
Upvotes: 53