tassock
tassock

Reputation: 1653

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!

Upvotes: 17

Views: 9445

Answers (3)

SleepyThread
SleepyThread

Reputation: 215

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

See Cucumber steps not automatically loaded when running features

Upvotes: 6

Alexis Perrier
Alexis Perrier

Reputation: 692

I ran into the same problem but the require feature did not solve it Instead I got around the problem by using tags

So instead of calling

cucumber features/accounts.feature

I call

cucumber --tags @account features

where "@account" goes before the scenario

@current Scenario: Anonymous user can create an account Given an anonymous user

works fine. All steps.rb files are loaded

Upvotes: 0

zetetic
zetetic

Reputation: 47578

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.

Upvotes: 29

Related Questions