Cucumber (Software)
Cucumber is a Behavior - Driven Development tool for textual specification of requirements for software and for automated checking of this description on their correct implementation.
Cucumber was originally written in the Ruby programming language for Ruby applications, but now it also supports other programming languages such as Java and all other Java Virtual Machine on the current programming languages, or C and Java script. In addition, there are projects that Cucumber still providing for other programming languages, and see themselves as part of the Cucumber family, including, for example, SpecFlow, an implementation for C #.
Example
Functionalities are described by means of the description language " Gherkin" in Cucumber As with most other Behavior Driven Development Tools. Gherkin uses natural written languages as a basis, only certain key words are treated specially. This functionality can be written in German needs at the beginning of the feature # language: de specify. In order for the keywords " functionality ", " basis " are, "Scenario ", " scenario plan ", "Examples ", "Received ", " Given ", " When", "Then ", " And " and " But," as well as "*" preset.
One such functionality described could for example consist of a single scenario and look like this:
# Language: en Functionality: Division Need to avoid stupid mistakes the cashier be able to calculate divisions Scenario: Regular numbers Suppose I have entered the number 3 in the calculator And I have the number 2 entered in the calculator When I click on " Division " Then should be issued as a result of 1.5 on the screen This functionality is described in Gherkin in German can now be processed for example in Ruby. ( " Steps" s) executed given the labeled using the key words lines in individual steps. When defining the steps ( en: "step definitions" ) to Cucumber Regular Expressions served to execute similar formulated steps can equally or by how the numbers 2, 3, and 1.5, respond to variable definitions in this example to can:
# Encoding: utf -8 begin require ' rspec / expectations '; rescue LoadError; require ' spec / expectations '; end require ' cucumber / formatter / unicode' $:. unshift ( File.dirname ( __FILE__ ) ' / / / lib.. . .') require ' calculator ' before do @ calc = Taschenrechner.new end After do end Given / I have the number (\ d ) input / do in Calculators | n | @ calc.push n.to_i end When / I on (\ w ) press / do | op | @ result = @ calc.send op end Then / should be as a result of output to the screen / do (*. ) | Result | @ result.should == result.to_f end Web Links
- Cucumber Homepage