I can't execute a simple test with cucumber for a project. I am on Intellij 13 Community, with cucumber plugin.
I wrote my feature file in my features directory, I have also implemented my steps, creating them with the help of the plugin. And my steps in the feature files are recognized by intellij, which can navigate and go to the step implementation.
But when I try to run my scenario, it always fails because for each step, it says "Undefined step : ".
Here is how is organized my project :
And as I said before, you can see that my steps are recognized by Intellij :
How is that possible, and how can I correct this?
Any help would be great!
EDITNow that I added options to my runner :
@CucumberOptions( monochrome = true,
features = "src/test/resources/features/",
format = { "pretty","html: cucumber-html-reports",
"json: cucumber-html-reports/cucumber.json" },
dryRun = false,
glue = "fr.tlasnier.cucumber" )
It works!
Yet, I noticed that before that, I had two scenario outline. One worked perfectly, the other one could not find step definition!
Really weird, since there were some steps in both scenario.
If Cucumber is telling you that your steps are undefined, when you have defined step definitions, this means that Cucumber cannot find your step definitions. You'll need to make sure to specify the path to your step definitions (glue path) correctly.
Cucumber is correctly indicating that the scenario has failed, which is being picked up by IntelliJ, as the summary at the top ("Done: Scenarios 1 of 1 failed") is correct. The scenario and feature failures are not being registered by the test runner, so the skipped state of the steps is being propagated to them.
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.
'next' skips everything below, it is kind of like 'return', which might work too. Program the steps like you usually would, but in the first line of the step, make an 'if' statement like the one above to not run the code below if you don't want to.
@RunWith(Cucumber.class)
@CucumberOptions( monochrome = true,
tags = "@tags",
features = "src/test/resources/features/",
format = { "pretty","html: cucumber-html-reports",
"json: cucumber-html-reports/cucumber.json" },
dryRun = false,
glue = "fr.tlasnier.cucumber" )
public class RunCucumber_Test {
//Run this
}
The class in which the steps are defined should be public. Anything else would throw the undefined step error.
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