Cucumber JVM undefined step
Asked Answered
M

4

23

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.

Moonset answered 13/2, 2014 at 11:44 Comment(0)
T
19
@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
}
Taenia answered 13/2, 2014 at 12:35 Comment(3)
That works now. What option might have bring the solution, and could you explain why? Because I still don't get it! ;)Moonset
Its very likely this option glue = "fr.tlasnier.cucumber". Because it says where to look for glue code (stepdefs and hooks)Taenia
I added it at the top of the .feature File. Worked.Devlen
A
4

In my case, i was running with intellij cucumber for java plugin, it doesnt automatically detect the glue, so you need to add it.

Run -> Edit Configurations Then on the Glue section, put the steps folder path.

Absquatulate answered 28/1, 2022 at 16:14 Comment(0)
C
2

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

Clack answered 14/7, 2017 at 6:36 Comment(0)
P
0

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.

Pollerd answered 20/11, 2016 at 3:10 Comment(1)
Very kind of you to share. Luckily, I moved on since :DMoonset

© 2022 - 2024 — McMap. All rights reserved.