Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running single cucumber feature doesn't load step definitions

I have a cucumber feature at features/object/create_object.feature. It passes when I execute all of my features with the 'cucumber' command. I'm trying to execute this feature by itself using these commands:

cucumber features/object/create_object.feature
rake features FEATURE=features/object/create_object.feature

However, all step definitions for this feature come up as undefined:

Using the default profile...
-------UUUUUUUUUUUU

I've also tried disabling the profile with "--no-profile", but to no avail. Thanks in advance!

like image 242
tassock Avatar asked Nov 11 '10 19:11

tassock


People also ask

What happens if Cucumber does not find a matching step definition?

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.

How do I get step definitions in Cucumber from feature file in eclipse?

Select project from the work space. Apply > Click on Run. Your step definitions suggestion file will be produced in the eclipse console for the test cases in your feature that do not have step definitions for a particular scenario. Copy the entire suggested step definitions steps.


2 Answers

I think you need to tell cucumber how to locate the step definitions when running features in subdirectories of ./features:

rake features FEATURE=features/object/create_object.feature REQUIRE=features

Using cucumber from the command line per your example didn't work for me -- I had to add --require:

cucumber --require features features/object/create_object.feature

More in this blog post.

like image 172
zetetic Avatar answered Nov 15 '22 16:11

zetetic


Better approach is to update your add -r features to cucumber.yml file.

See Cucumber steps not automatically loaded when running features

like image 30
SleepyThread Avatar answered Nov 15 '22 17:11

SleepyThread