Story Driven Development Recipes with Cucumber
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):
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 0.1.99.10 is available at GitHub.