Story Driven Development Recipes with Cucumber

| by Sebastien Auvray Follow 0 Followers on Mar 03, 2009. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

Behavior Driven Development's (BDD) popularity cannot be denied. It is a response to Test Driven Development (TDD) and was introduced by Dan North in 2003. BDD encourages collaboration between the various parties involved in a software project: developers, QA and non-technical or business analyst.

Easy creation and use of DSLs in Ruby allowed the birth of many BDD frameworks, such as RSpec. Cucumber, written by Aslak Hellesøy is another example, which can also be used to test Java, .NET and Flex code. It can execute plain-text documents as automated functional tests.

Here is a typical scenario example (from the project Wiki):

Feature: Search courses
  In order to ensure better utilization of courses
  Potential students should be able to search for courses

  Scenario: Search by topic
    Given there are 240 courses where neither has the topic "biology" 
    And there are 3 courses A,B,C that each have "biology" as one of the topics
    When I search for "biology" 
    Then I should see a the following courses:
      | title |
      | A     |
      | B     |
      | C     |

Then you can implement the actual code this recipe describes, and iterate with test failure until success. Cucumber supports highlighting of failing or successful parts of the scenario (Image from the Cucumber website):

Tests failure

The format used to write Cucumber recipes is the Gherkin language, which can be skinned for different natural languages, ie. the keywords like "Given", "And", etc. can also be written in languages like French, German, etc. The natural language text to the right of the keywords is interpreted by a programmatic step definition, ie. it executes code to perform the step.

There are many different ways to use Cucumber such as Web app integration testing for sysadmins or to Integrate Distributed Systems and Test Messaging or PDF Writing tests.

Cucumber 0.1.16 version is available as a Ruby Gem and is available at GitHub.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you