How to make Cucumber run faster

Speed up the startup time of cucumber for TDD/BDD tests

Getting started with Behaviour Driven Development with Cucumber and noticed that it takes more time to startup than actually run the scenarios.

Compare this:

2 scenarios (2 passed)
4 steps (4 passed)

real 0m16.013s
user 0m14.850s
sys 0m0.814s

Cucumber reports 0m2.252s but time says 0m16.013s, thats ~~14seconds of difference.

Remember: user time represents the time the application spent on user-mode, actually running the code, where as sys represents the time spent on kernel. real is the full time from start to finish

Using spork as a DRb server

(DRb = Distributed Ruby server)
Note from spork site

Because Spork uses Kernel.fork, it only works on POSIX systems. This means Windows users are not invited to this party. Sorry :(

For your rails app, follow this procedure:

Add spork to your Gemfile

gem 'spork'

Run bundle install

and rails g cucumber:install --spork

Finally run spork server on the background:

bundle exec spork cuc &

And happily run tests:

cucumber features/...

The conclusion: it works!

2 scenarios (2 passed)
4 steps (4 passed)

real 0m3.946s
user 0m0.658s
sys 0m0.059s


One thought on “How to make Cucumber run faster

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s