Robust Software

Tales of a code samurai

Cucumber

We’re looking at automating our acceptance criteria at work and we’ve chosen Cucumber for doing it. Yesterday I scoured the web for useful articles and so on to find out what the established best practices are for working with Cucumber. This is a link dump of the things I found that were useful.

We’re going to be using Cucumber for running the tests, RSpec for our assertions and Watir to drive the browser.

This was a nice overview of the various components you use as part of your cucumber tests (we’re using Watir rather than Webrat and Selenium at the moment):

Cucumber overview

Source

I found this useful description of how Cucumber fits into your testing strategy with a slant on legacy code. Particularly relevant as we want to use Cucumber to add some regression tests to existing sites.

I was particularly impressed with the Cucumber wiki it’s a treasure trove of information on using cucumber, particularly useful were:

Running cucumber --help shows you the command line arguments available, I can see tags being very useful for focusing test runs to the features being actively developed as part of the build and then leave the remaining features for a nightly/weekly run.

There’s also a great Railscast on getting started with cucumber and another Railscast that dives a bit deeper with cucumber.

There is also a Gherkin editor with syntax highlighting and autocomplete that makes writing your Gherkin scripts a bit easier. I also found a Gherkin plugin for Visual Studio but I don’t think anyone installed this so I’m not sure if it works.

As we were looking to build some standards for our Gherkin vocabulary and Cucumber step definitions I had a look at what gets added to Rails when you install the plugin and found this set of standard step definitions for working with Watir. These helped make wiring up the Gherkin scripts a breeze.

That’s all I’ve got for now, hope this saves someone some time.