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 ...

Get The Cucumber Book now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.