Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get cucumber/guard to filter on tags like @wip?

I'm running spork and guard and all has been going very well with my RSpec tests which were all run correctly. In order to speed up the tests I could successfully filter my RSpec tests with tags I placed in my .rspec file.

.rspec

--colour
--debug
--tag focus
--tag now

Unfortunately though I have not been able to filter my cucumber tags. Every time cucumber runs it runs either everything or just the file that changed.

How can I get cucumber/spork/guard to respect tags like @wip, @now etc and run only those tests? Is there some equivalent to the .rspec file for cucumber tags?

like image 306
Peter Nixey Avatar asked Feb 08 '12 12:02

Peter Nixey


1 Answers

You could use a cucumber profile to define the tags that you want to execute. Using the YML file, you can define a profile that execute your @wip tags:

wip: --tags @wip

More info at:

https://github.com/cucumber/cucumber/wiki/cucumber.yml

You can also just run cucumber from the command line and pass it the -t argument:

cucumber -t @wip,@now

From the help (cucumber -h):

Only execute the features or scenarios with tags matching TAG_EXPRESSION. Scenarios inherit tags declared on the Feature level. The simplest TAG_EXPRESSION is simply a tag. Example: --tags @dev. When a tag in a tag expression starts with a ~, this represents boolean NOT. Example: --tags ~@dev. A tag expression can have several tags separated by a comma, which represents logical OR. Example: --tags @dev,@wip. The --tags option can be specified several times, and this represents logical AND. Example: --tags @foo,~@bar --tags @zap. This represents the boolean expression (@foo || !@bar) && @zap

Hence, in theory we can use the guardfile with these options:

guard 'cucumber', :cli => "--drb --tags @now" do
  watch(%r{^features/.+\.feature$})
  ...
end
like image 117
Dan Garland Avatar answered Oct 23 '22 20:10

Dan Garland