Running Cucumber from Rake

Many projects use a build tool to perform common tasks. For Ruby projects, Rake is the de facto build tool. Cucumber has a Rake task that makes it easy to run Cucumber from Rake. If you are using Cucumber-Rails, which we describe in Chapter 14, Bootstrapping Rails, you will have Rake tasks set up automatically.

If you are not using Rake, it’s still easy to set it up yourself. Try adding this to a Rakefile in the root of your project:

 
require ​'cucumber/rake/task'
 
 
Cucumber::Rake::Task.new ​# defines a task named cucumber

Now you can run your Cucumber features from Rake:

 
$ ​rake cucumber

Profiles from cucumber.yml will be picked up when you run Cucumber from Rake, but you can also define Cucumber command-line options from the Rakefile:

 
Cucumber::Rake::Task.new(​'cucumber_progress'​) ​do​ |t|
 
t.cucumber_opts = ​%w{--format progress}
 
end

Now that you know how to run Cucumber both from its native command-line interface and from Rake, you can also make your continuous integration server run it. Cucumber (or Rake) exits with a status code of 1 if any scenarios fail, so your continuous integration server can properly detect failure.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.57.126