Cucumber (software)

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Cucumber
Developer(s) Aslak Hellesøy,[1] Joseph Wilk,[2] Matt Wynne,[3] Gregory Hnatiuk,[4] Mike Sassak[5]
Stable release 1.0.2 / July 17, 2011
Written in Ruby
Operating system Cross-platform
Type Behavior driven development framework / Test tool
License MIT License
Website cukes.info

Cucumber is a tool for running automated acceptance tests written in a behavior-driven development (BDD) style. Cucumber is written in the Ruby programming language.[6][7] Cucumber projects are available for other platforms beyond Ruby. Some use Ruby Cucumber with a bridge into the target language (e.g. cuke4php and cuke4lua). Others use the Gherkin parser but implement everything else in the target language.[8] Cucumber allows the execution of feature documentation written in business-facing text.

Example[edit]

A feature definition, with a single scenario:[9]

Feature: Division
  In order to avoid silly mistakes
  Cashiers must be able to calculate a fraction

  Scenario: Regular numbers
    * I have entered 3 into the calculator
    * I have entered 2 into the calculator
    * I press divide
    * The result should be 1.5 on the screen

The execution of the test implicit in the feature definition above requires the definition, using the Ruby language, of a few "steps":[10]

Before do
  @calc = Calculator.new
end
 
After do
end
 
Given /I have entered (\d+) into the calculator/ do |n|
  @calc.push n.to_i
end
 
When /I press (\w+)/ do |op|
  @result = @calc.send op
end
 
Then /the result should be (.*) on the screen/ do |result|
  @result.should == result.to_f
end

See also[edit]

References[edit]

  1. ^ "Aslak Hellesøy". Aslakhellesoy.com. Retrieved 2012-01-24. 
  2. ^ "Joseph Wilk | on AI, The Web, Usability, Testing & Software process". Blog.josephwilk.net. Retrieved 2012-01-24. 
  3. ^ "Tea-Driven Development". Blog.mattwynne.net. Retrieved 2012-01-24. 
  4. ^ "ghnatiuk's Profile". GitHub. Retrieved 2012-01-24. 
  5. ^ "msassak's Profile". GitHub. Retrieved 2012-01-24. 
  6. ^ "The Pragmatic Bookshelf | The Cucumber Book". Pragprog.com. Retrieved 2012-01-24. 
  7. ^ "The Pragmatic Bookshelf | The RSpec Book". Pragprog.com. 2010-12-02. Retrieved 2012-01-24. 
  8. ^ Lawrence, Richard. "Cucumber". Retrieved 2012-04-16. 
  9. ^ aslakhellesoy (2012-01-15). "examples/i18n/en/features/division.feature at master from cucumber/cucumber". GitHub. Retrieved 2012-01-24. 
  10. ^ aslakhellesoy (2012-01-15). "examples/i18n/en/features/step_definitons/calculator_steps.rb at master from cucumber/cucumber". GitHub. Retrieved 2012-01-24. 

External links[edit]