cucumber
DESCRIPTION
TRANSCRIPT
Cucumber
What it is
Straight-forward languageCommon LanguageCommunication ToolConcrete ExamplesDescribes behavior
Behavior Driven Development (BDD)
first: describe what the software does
second: write the code to fulfill it
(behavior drives development)
BDD
Separate software design (one job)
from
writing code (a different job)
Cucumber
software for BDD
that takes plain english,
Ruby translations of plain english,
and runs integration test/stories against your application
Cucumber’s Natural Habitat
FeaturesFeatures
Step Definitions
Step Definitions
Ruby MagicRuby Magic
Application Under TestApplication Under Test
Plain textFilename ends in .feature
Describes behavior of systemLives in features directory
Ruby codeFilename ends in.rb
Does regex match of text from feature filesLives in features/step_definition directory
Your preferred gems go hereReferenced in features/support/env.rb
We will be testing a web-page
Cucumber - Example
Cucumber benefits
it facilitates thinking about features and problems in the language of business rather than the language of code
it requires you to focus on data in your tests
it can be easily included in a continuous integration environment
it is easily shared with non-developer users
Easy re-factor with confidence
Recap -- Features• Plain text files that end in .feature
• They live in the root of the features directory
• Given, When, Then, And, But are trigger words
• They matter most for readability
• Descriptive text can go at the top
• There are several approaches to abstract features and make them more readable
• Usage depends on intent & team understanding
Recap -- Step Definitions
• Ruby files that live in features/step_definitions
• Matches plain text from feature files
• Stores it into a variable
• You can set this to a class level variable for use across your test scenario
• Use a gem to get where you need to go (e.g. Capybara for web testing)
Recap -- System Setup
• Gems you want to use can be added to env.rb
• It lives in the features/support directory
• If/when you create helper methods, create a ruby file and place them in this directory
• If you add something to your test harness and execution order is important, place it in env.rb – it loads before everything else
Cucumber: Let’s use it!
End of presentation--now to the terminal.