1: Describe behaviour in plain text
2: Write a step definition in Ruby
3: Run and watch it fail
4. Write code to make the step pass
5. Run again and see the step pass
6. Repeat 2-5 until green like a cuke
7. Repeat 1-6 until the money runs out
Cucumber lets software development teams describe how software should behave in plain text. The text is written in a business-readable domain-specific language and serves as documentation, automated tests and development-aid - all rolled into one format.
Cucumber works with Ruby, Java, .NET, Flex or web applications written in any language. It has been translated to over 40 spoken languages.
Cucumber also supports more succinct tests in tables - similar to what FIT does. Dig around in the examples and documentation to learn more about Cucumber tables.
Background and Credits
Cucumber is Aslak Hellesøy’s rewrite of RSpec’s “Story runner”, which was originally written by Dan North. (Which again was a rewrite of his first implementation - RBehave. RBehave was his Ruby port of JBehave). Early versions of the RSpec “Story Runner” required that stories be written in Ruby. Seeing how much this sucked David Chelimsky added plain text support with contributions from half a dozen other people.
In April 2008, Aslak Hellesøy started the Cucumber project to address the internal design flaws and usability problems of the RSpec Story Runner (Yes - Cucumber also has warts on the inside). Joseph Wilk and Ben Mabey joined as regular contributors when Cucumber was just a little Gherkin. Matt Wynne joined the Cucumber team in September 2009 after. Mike Sassak and Gregory Hnatiuk joined in October 2009 after their great work on a faster parser for Cucumber. In addition to the core team over
160 250 developers have contributed patches, bugfixes, tears and joy.
Cucumber's plain text DSL (Gherkin) somehow came out from the Agile community, mostly based on distillations made by Dan North, Chris Matts, Liz Keogh, David Chelimsky and dozens of people on the RSpec and Cucumber mailing lists. And me.
Free Chapter from Specification by Example!
July 24, 2009 - Ruby Classes via Cucumber by Joseph Leddy & Leah Welty-Rieger at Obtiva.
Apr 27, 2009 - Ryan Bates from RailsCasts dives into tables, scenario outlines and tags.
Apr 01, 2009 - Bryan Liles gives an introduction to Cucumber, Webrat and Integrity.
Mar 30, 2009 - Ryan Bates from RailsCasts demonstrates how to get started with Cucumber and Ruby on Rails.
Feb 04, 2009 - Jeff Dean talks about his experience with Cucumber at Pivotal Labs.
Jan 18, 2009 - Dave Hoover demonstrates how to use Watir with Cucumber. Actually, he uses his own library SafariWatir, but you could easily swap it with Watir, FireWatir, ChromeWatir or Celerity. Sorry - no sound.
Aslak Hellesøy presented Cucumber at the EuroSTAR conference in Stockholm on Thursday 3rd of December.
Aslak Hellesøy presented Cucumber at RailsConf in Las Vegas and got some good press.
You need Ruby installed. Then just run
gem install cucumber
from a command prompt. Now, run
The wiki has more information.
A major contributory factor to the success of the BBC's digital Olympics was the use of Cucumber to collaboratively specify requirements, guide development, drive automated tests and describe the system.
—Aidy Lewis, Test Discipline Lead BBC Future Media - News and Knowledge
My attention-span is short so I may be forgetting something but I think Cucumber could be the most important piece of software released in 2008 for Ruby-based developers.
If you’re looking for a higher level of abstraction in your tests, it’s definitely worth checking out.
I finally looked into cucumber last week and immediately loved it. Within a couple hours I had several features written for an existing application. By the end of the next day, our whole team was writing cucumber features, and enjoying it! Cucumber seems to have brought back an excitement to testing that I haven’t felt for a while (since my first few weeks with RSpec).
Seeing what you guys are doing is just over-the-top cool. BDD is great, Domain Driven Design is great. Stuff I wish I knew 20 years ago.
I started using Cucumber yesterday and it was really easy.
Cucumber allows you to write feature documentation in Plain Text. It means you could sit with your Client or Business Analyst to write down the features to be build on your application.
Cucumber is fast becoming the standard for acceptance testing in Rails. Cucumber is a BDD tool for specification of application features and user scenarios in plain text. It’s powered by Ruby, supports over 20 spoken languages, and integrates with other testing platforms.
God DAMN I want a BDD tool for Python that runs as well as cucumber 0.0003 or whatever it’s called does already. Dammit.
Continuous Integration Blueprints: How to Build an Army of Killer Robots With Hudson and Cucumber.