Ruby on Rails: Cucumber: how do I Rake a single feature?
Solution 1
To answer the Rake question directly, you can use:
rake FEATURE=features/adding_products.feature cucumber
but the Using Rake wiki page advises against using rake for anything but on a CI server because it's slower to start. Just use the cucumber command line instead, i.e.:
cucumber features/adding_products.feature
or, if you must:
bundle exec cucumber features/adding_products.feature
Solution 2
The correct way is to run it using the cucumber
executable if you're using Rails 2, or bundle exec cucumber
if you're using Rails 3 (and thus Bundler).
To run a specific feature:
[command] features/signing_in.feature
To run a specific scenario from that feature:
[command] features/signing_in.feature:6
The line number can be any line inside that feature, but is usually the first line.
If you run rake cucumber:ok
and some scenarios fail, at the bottom of the output you will see something like this:
cucumber features/sigining_in.feature:6 # Signing in via form
You can triple-click this line and paste it into your terminal to just run that scenario.
Solution 3
The rake did not worked for me. Just replaced the rake with bundle exec, and it worked. below is a sample.
bundle exec cucumber features/users/signup.feature --require features
Solution 4
I'm not sure cucumber's tag feature was available when the question asked, but i prefer setting @active
tag
@active
Feature ..
or
@active
Scenario ..
and
cucumber --tags @active
Solution 5
I like the short command $ cucumber -n
.
If:
Feature: Manage Contents
In order to manage instances from custom content types
…
Then:
$ cucumber -n "Manage Contents"
Related videos on Youtube
Comments
-
NullVoxPopuli over 3 years
Reason why I want to run them individually, is because I need to have them individually set up in my Rake file, because, My Java Heap Space fills up when I run them all together
-
uKolka almost 14 yearsJava Heap Space? How does Java figure into this if you're using a Rake/Rails/Cucumber stack?
-
ap2 over 12 yearsrunning on jruby, i'm guessing
-
NullVoxPopuli over 12 yearsnot directly. I'm using some libraries along with cucumber that use jruby though. I think CapyBara is one. =\
-
-
Bastien about 13 yearsTo run a single scenario, you can also type this:
cucumber --name "Signing in via form"
-
sivabudh almost 13 yearsFor me, this works
cucumber -r features features/adding_products.feature
-
Indika K almost 11 yearsWorked for me too. If I omit the --require features cucumber failed to identify the step definitions.
-
AMIC MING almost 11 yearsfor new version, you can do this too - bundle exec cucumber features/adding_products.feature
-
comandante N over 10 yearsright, had the same problem. the alternative apparently is to hard code that
--require features
replacig this line in config/cucumber.ymlstd_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
withstd_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip --require features/"
see this question -
konyak about 10 yearsNote: "Any feature that is located inside a sub-directory of features directory must require features [--require features]." Per github.com/cucumber/cucumber/wiki/Running-Features
-
Alex Pan over 8 yearsThank you Ryan and Bastien. This should be the accepted answer.
-
AMIC MING over 8 yearsGood one Buddy, you are the Genius