8. Features
Features Plain text
Filename ends in .feature
Describes behavior of system
Lives in features directory
Step
Step Ruby code
Definitions
Definitions Filename ends in.rb
Does regex match of text from feature files
Lives in features/step_definition directory
Ruby Magic
Ruby Magic Your preferred gems go here
Referenced in features/support/env.rb
Application
Application We will be testing a web-page
Under Test
Under Test
10. 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
11. 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
12. 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)
13. 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
#1 – in this case, English #2 A common language between the business and the tech team Helping you understand better what needs to be built And, helps the business better understand what you are building #3 Cucumber is a communication tool more than anything – automation is just a secondary benefit #4 Examples are powerful stuff They have the power to turn high-level acceptance criteria into specific & actionable acceptance tests (either to be carried out manually, or, with automation) They also engage our brains enabling us to visualize scenarios & figure out edge cases we may otherwise miss #5 This is all buttressed by the idea of describing the behavior of an application you are hoping to verify
Okay, let’s change gears and step through the mechanics of Cucumber Cucumber uses Gherkin which is a universal To be clear -- Gherkin can be used in other BDD frameworks that use other programming languages For our purposes, we’ll be using Cucumber & Ruby So, in Cucumber, there is a default folder structure – let’s step through it