15
votes

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 :

file organization

And as I said before, you can see that my steps are recognized by Intellij :

feature file

How is that possible, and how can I correct this?

Any help would be great!

EDIT

Now 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.

3

3 Answers

16
votes
@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
}
1
votes

The class in which the steps are defined should be public. Anything else would throw the undefined step error.

0
votes

I've met the same problem. And found that if the package where step definitions exists has not been created in the corresponding source folder. You can try to create a class under fr.tlasnier.cucumber.step, then idea should be able to find the steps. I think it is a bug in Idea.