问题
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.
回答1:
Turns out I had the Gherkin plugin but not the Cucumber for Java plugin.
回答2:
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.
回答3:
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.
回答4:
"Undefined" step error message would appear if you import a new BDD project.
This error could appear due to two reasons.
- If you have not installed the "Cucumber for Java" plugin.
- If you import any BDD projects then it will not detect step definition file.
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.
回答5:
Most probably you need to install the cucumber for java plugin, if already installed then you need to enable from File>>Settings>>pugins.
回答6:
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.
回答7:
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.
回答8:
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.
回答9:
The issue was fixed after updating the Intelij to the latest version and after updating the cucumber and gherkin intelij plugins
来源:https://stackoverflow.com/questions/24858662/undefined-step-definitions-in-intellij