SlideShare ist ein Scribd-Unternehmen logo
1 von 21
presents




                        RELEASE THE GHERKIN!
©2012 AgilityFeat Inc
© 2012 AgilityFeat, Inc.
What it is
•   Straight-forward language
•   Common Language
•   Communication Tool
•   Concrete Examples
•   Describes behavior




                     © 2012 AgilityFeat, Inc.
#protip

“make readability your main goal.
Otherwise, a reader can easily feel more
like they’re a reading computer program
than a specification document”
- Aslak Hellesøy (creator of Cucumber)


                © 2012 AgilityFeat, Inc.
Cucumber’s Natural Habitat




         © 2012 AgilityFeat, Inc.
Features                 Plain text
                         Filename ends in .feature
                         Describes behavior of system
                         Lives in features directory


Step                     Ruby code
Definitions              Filename ends in.rb
                         Does regex match of text from feature files
                         Lives in features/step_definition directory


Ruby Magic               Your preferred gems go here
                         Referenced in features/support/env.rb




Application              We will be testing a web-page
Under Test


              © 2012 AgilityFeat, Inc.
Example
Feature: Brown Bag Demo

Scenario: Google Search
   Given I am on “http://www.google.com”
   When I search for “Hello World”
   Then I should see results containing the search phrase




                      © 2012 AgilityFeat, Inc.
Solution
Given /^I am on “(*^”+*)”$/ do |arg1|
    visit(arg1)
end

When /^I search for “(*^”+*)”$/ do |arg1|
    @search_phrase = arg1
    within(:css, “#gbqfqw”) do
        fill_in ‘q’, :with => @search_phrase
    end
end

Then /^I should see results containing the search phrase$/ do
    page.should have_content(@search_phrase)
end


                                © 2012 AgilityFeat, Inc.
Feature: Class Demonstration

Scenario: Show a Hello World
  Given I want to say “Hello World!”
  When I execute the application
  Then I should see the message




                © 2012 AgilityFeat, Inc.
Feature: Class Demonstration

Scenario: Show a Hello World
  Given I want to say “Hello World!”
  When I execute the application
  Then I should see the message
  And it should be italic
  But it should not be bold



                © 2012 AgilityFeat, Inc.
Feature: Class Demonstration

Scenario: Show a Hello World
  * I want to say “Hello World!”
  * I execute the application
  * I should see the message
  * it should be italic
  * it should not be bold



                © 2012 AgilityFeat, Inc.
Feature: Class Demonstration

Scenario: Show a Hello World
  Given I want to say “Hello World!”
  When I execute the application
  Then I should see the message
  And it should be italic
  But it should not be bold



                © 2012 AgilityFeat, Inc.
Feature: Class Demonstration
In order to expose you to new ideas
As an instructor
I want to show you an end-to-end example

Scenario: Show a Hello World
  Given I want to say “Hello World!”
  When I execute the application
  Then I should see the message
  And it should be italic
  But it should not be bold
                © 2012 AgilityFeat, Inc.
Feature: Class Demonstration
As an instructor
I would like to show an end-to-end example
So that I can expose you to new ideas

Background:
  Given I want to say “Hello World!”
  When I execute the application
  Then I should see the message

Scenario: Show an italicized Hello World
   And it should be italic

Scenario: Show a bold Hello World
   But it should not be2012 AgilityFeat, Inc.
                      ©
                        bold
Feature: International Display

Scenario: Display Hello World in English
   Given I want to say “Hello World!”
   When I execute the application
   And I specify English as the language
   Then the output should be “Hello World!”

Scenario: Display Hello World in Spanish
   Given I want to say “Hello World!”
   When I execute the application
   And I specify Spanish as the language
   Then the output should be “¡Hola, mundo!”

Scenario: Display Hello World in German
   Given I want to say “Hello World!”
   When I execute the application
   And I specify German as the language
   Then the output should © 2012 AgilityFeat, Inc.
                           be “Hallo Welt!”
Feature: Internationalize Hello World

Scenario Outline: Display in multiple languages
   Given I want to say “Hello World!”
   When I execute the application
   And I specify “<language>” as the language
   Then the output should be “<output>”

Examples:
   | language    | output                        |
   | English     | Hello World!                  |
   | Spanish     | ¡Hola, mundo!                 |
   | German      | Hallo Welt!                   |
                      © 2012 AgilityFeat, Inc.
Feature: Travel The World

Scenario: Keep Track Of Visits
  Given a list like this:
  | Location         | Times visited |
  | Costa Rica       |    0          |
  | Germany          |    0          |
  When I travel to Costa Rica
  Then the list should look like this:
  | Location         | Times visited |
  | Costa Rica       |    1          |
  | Germany          |    0          |
                     © 2012 AgilityFeat, Inc.
Doc strings
Scenario: Look up hostel reservation e-mail
When I search for “Alexander House”
Then I should see the following message:
"""
Welcome Mr. Haeffner.
You’ll be staying in the bunk house this visit.
Please refrain from stealing our towels (again).
""”

                    © 2012 AgilityFeat, Inc.
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

                     © 2012 AgilityFeat, Inc.
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)


                       © 2012 AgilityFeat, Inc.
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


                       © 2012 AgilityFeat, Inc.

Weitere ähnliche Inhalte

Andere mochten auch

Agile testing for mere mortals
Agile testing for mere mortalsAgile testing for mere mortals
Agile testing for mere mortals
Dave Haeffner
 
Mobile automation using selenium cucumber & appium
Mobile automation using selenium cucumber & appiumMobile automation using selenium cucumber & appium
Mobile automation using selenium cucumber & appium
Selenium Cucumber
 
Zbinden G - paintings
Zbinden G - paintingsZbinden G - paintings
Zbinden G - paintings
artalaferme
 
Manual snagit grupo A
Manual snagit grupo AManual snagit grupo A
Manual snagit grupo A
sasanchezc
 

Andere mochten auch (20)

The Testable Web
The Testable WebThe Testable Web
The Testable Web
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Agile testing for mere mortals
Agile testing for mere mortalsAgile testing for mere mortals
Agile testing for mere mortals
 
Selenium Basics
Selenium BasicsSelenium Basics
Selenium Basics
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
Selenium Users Anonymous
Selenium Users AnonymousSelenium Users Anonymous
Selenium Users Anonymous
 
Open Source Investing
Open Source InvestingOpen Source Investing
Open Source Investing
 
Selenium Frameworks
Selenium FrameworksSelenium Frameworks
Selenium Frameworks
 
How To Find Information On Your Own
How To Find Information On Your OwnHow To Find Information On Your Own
How To Find Information On Your Own
 
Selenium Tips & Tricks
Selenium Tips & TricksSelenium Tips & Tricks
Selenium Tips & Tricks
 
Agile Arizona 2016 - Awesome Teams: Games for Continuous (Extreme?) Teaming
Agile Arizona 2016 - Awesome Teams: Games for Continuous (Extreme?) TeamingAgile Arizona 2016 - Awesome Teams: Games for Continuous (Extreme?) Teaming
Agile Arizona 2016 - Awesome Teams: Games for Continuous (Extreme?) Teaming
 
Mobile automation using selenium cucumber & appium
Mobile automation using selenium cucumber & appiumMobile automation using selenium cucumber & appium
Mobile automation using selenium cucumber & appium
 
Zbinden G - paintings
Zbinden G - paintingsZbinden G - paintings
Zbinden G - paintings
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully
 
Awesome Test Automation Made Simple w/ Dave Haeffner
Awesome Test Automation Made Simple w/ Dave HaeffnerAwesome Test Automation Made Simple w/ Dave Haeffner
Awesome Test Automation Made Simple w/ Dave Haeffner
 
Manual snagit grupo A
Manual snagit grupo AManual snagit grupo A
Manual snagit grupo A
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupSelenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
 
Ontario Disability Support Program (ODSP) - Know Your Benefits
Ontario Disability Support Program (ODSP) - Know Your BenefitsOntario Disability Support Program (ODSP) - Know Your Benefits
Ontario Disability Support Program (ODSP) - Know Your Benefits
 
Continuous Testing Meets the Classroom at Code.org
Continuous Testing Meets the Classroom at Code.orgContinuous Testing Meets the Classroom at Code.org
Continuous Testing Meets the Classroom at Code.org
 

Ähnlich wie Cucumber Crash Course

Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13
Stephan Hochdörfer
 
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
mfrancis
 
Interference with High level language.pdf
Interference with High level language.pdfInterference with High level language.pdf
Interference with High level language.pdf
ARslan Ahmad
 
Make Mobile Apps Quickly
Make Mobile Apps QuicklyMake Mobile Apps Quickly
Make Mobile Apps Quickly
Gil Irizarry
 
Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructure
Lindsay Holmwood
 

Ähnlich wie Cucumber Crash Course (20)

Behaviour Driven Development
Behaviour Driven DevelopmentBehaviour Driven Development
Behaviour Driven Development
 
Fukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - OpalFukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - Opal
 
Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014
Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014
Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014
 
Multi Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoMulti Lingual Websites In Umbraco
Multi Lingual Websites In Umbraco
 
Dynamic Languages In The Enterprise (4developers march 2009)
Dynamic Languages In The Enterprise (4developers march 2009)Dynamic Languages In The Enterprise (4developers march 2009)
Dynamic Languages In The Enterprise (4developers march 2009)
 
React Native? A developer's perspective
React Native? A developer's perspectiveReact Native? A developer's perspective
React Native? A developer's perspective
 
How to make multilingual plugins and themes
How to make multilingual plugins and themesHow to make multilingual plugins and themes
How to make multilingual plugins and themes
 
Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13
 
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
 
How do I - Create a Native Interface - Transcript.pdf
How do I - Create a Native Interface - Transcript.pdfHow do I - Create a Native Interface - Transcript.pdf
How do I - Create a Native Interface - Transcript.pdf
 
Object Oriented Views / Aki Salmi
Object Oriented Views / Aki SalmiObject Oriented Views / Aki Salmi
Object Oriented Views / Aki Salmi
 
Green Light for the Apps with Calaba.sh - DroidCon Paris 2014
Green Light for the Apps with Calaba.sh - DroidCon Paris 2014Green Light for the Apps with Calaba.sh - DroidCon Paris 2014
Green Light for the Apps with Calaba.sh - DroidCon Paris 2014
 
Interference with High level language.pdf
Interference with High level language.pdfInterference with High level language.pdf
Interference with High level language.pdf
 
Better problem solving through scripting: How to think through your #eprdctn ...
Better problem solving through scripting: How to think through your #eprdctn ...Better problem solving through scripting: How to think through your #eprdctn ...
Better problem solving through scripting: How to think through your #eprdctn ...
 
Make Mobile Apps Quickly
Make Mobile Apps QuicklyMake Mobile Apps Quickly
Make Mobile Apps Quickly
 
Barcelona Multilanguage
Barcelona MultilanguageBarcelona Multilanguage
Barcelona Multilanguage
 
Building mobile apps with PhoneGap and Titanium appcelerator
Building mobile apps with PhoneGap and Titanium appceleratorBuilding mobile apps with PhoneGap and Titanium appcelerator
Building mobile apps with PhoneGap and Titanium appcelerator
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLC
 
Ruby, Meet iPhone
Ruby, Meet iPhoneRuby, Meet iPhone
Ruby, Meet iPhone
 
Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructure
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Cucumber Crash Course

  • 1. presents RELEASE THE GHERKIN! ©2012 AgilityFeat Inc
  • 3. What it is • Straight-forward language • Common Language • Communication Tool • Concrete Examples • Describes behavior © 2012 AgilityFeat, Inc.
  • 4. #protip “make readability your main goal. Otherwise, a reader can easily feel more like they’re a reading computer program than a specification document” - Aslak Hellesøy (creator of Cucumber) © 2012 AgilityFeat, Inc.
  • 5. Cucumber’s Natural Habitat © 2012 AgilityFeat, Inc.
  • 6. Features Plain text Filename ends in .feature Describes behavior of system Lives in features directory Step Ruby code Definitions Filename ends in.rb Does regex match of text from feature files Lives in features/step_definition directory Ruby Magic Your preferred gems go here Referenced in features/support/env.rb Application We will be testing a web-page Under Test © 2012 AgilityFeat, Inc.
  • 7. Example Feature: Brown Bag Demo Scenario: Google Search Given I am on “http://www.google.com” When I search for “Hello World” Then I should see results containing the search phrase © 2012 AgilityFeat, Inc.
  • 8. Solution Given /^I am on “(*^”+*)”$/ do |arg1| visit(arg1) end When /^I search for “(*^”+*)”$/ do |arg1| @search_phrase = arg1 within(:css, “#gbqfqw”) do fill_in ‘q’, :with => @search_phrase end end Then /^I should see results containing the search phrase$/ do page.should have_content(@search_phrase) end © 2012 AgilityFeat, Inc.
  • 9. Feature: Class Demonstration Scenario: Show a Hello World Given I want to say “Hello World!” When I execute the application Then I should see the message © 2012 AgilityFeat, Inc.
  • 10. Feature: Class Demonstration Scenario: Show a Hello World Given I want to say “Hello World!” When I execute the application Then I should see the message And it should be italic But it should not be bold © 2012 AgilityFeat, Inc.
  • 11. Feature: Class Demonstration Scenario: Show a Hello World * I want to say “Hello World!” * I execute the application * I should see the message * it should be italic * it should not be bold © 2012 AgilityFeat, Inc.
  • 12. Feature: Class Demonstration Scenario: Show a Hello World Given I want to say “Hello World!” When I execute the application Then I should see the message And it should be italic But it should not be bold © 2012 AgilityFeat, Inc.
  • 13. Feature: Class Demonstration In order to expose you to new ideas As an instructor I want to show you an end-to-end example Scenario: Show a Hello World Given I want to say “Hello World!” When I execute the application Then I should see the message And it should be italic But it should not be bold © 2012 AgilityFeat, Inc.
  • 14. Feature: Class Demonstration As an instructor I would like to show an end-to-end example So that I can expose you to new ideas Background: Given I want to say “Hello World!” When I execute the application Then I should see the message Scenario: Show an italicized Hello World And it should be italic Scenario: Show a bold Hello World But it should not be2012 AgilityFeat, Inc. © bold
  • 15. Feature: International Display Scenario: Display Hello World in English Given I want to say “Hello World!” When I execute the application And I specify English as the language Then the output should be “Hello World!” Scenario: Display Hello World in Spanish Given I want to say “Hello World!” When I execute the application And I specify Spanish as the language Then the output should be “¡Hola, mundo!” Scenario: Display Hello World in German Given I want to say “Hello World!” When I execute the application And I specify German as the language Then the output should © 2012 AgilityFeat, Inc. be “Hallo Welt!”
  • 16. Feature: Internationalize Hello World Scenario Outline: Display in multiple languages Given I want to say “Hello World!” When I execute the application And I specify “<language>” as the language Then the output should be “<output>” Examples: | language | output | | English | Hello World! | | Spanish | ¡Hola, mundo! | | German | Hallo Welt! | © 2012 AgilityFeat, Inc.
  • 17. Feature: Travel The World Scenario: Keep Track Of Visits Given a list like this: | Location | Times visited | | Costa Rica | 0 | | Germany | 0 | When I travel to Costa Rica Then the list should look like this: | Location | Times visited | | Costa Rica | 1 | | Germany | 0 | © 2012 AgilityFeat, Inc.
  • 18. Doc strings Scenario: Look up hostel reservation e-mail When I search for “Alexander House” Then I should see the following message: """ Welcome Mr. Haeffner. You’ll be staying in the bunk house this visit. Please refrain from stealing our towels (again). ""” © 2012 AgilityFeat, Inc.
  • 19. 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 © 2012 AgilityFeat, Inc.
  • 20. 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) © 2012 AgilityFeat, Inc.
  • 21. 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 © 2012 AgilityFeat, Inc.

Hinweis der Redaktion

  1. Thanks for joining meToday we are going to step through a crash course on Cucumber &amp; GherkinWe will:Start with the benefitsProvide a brief primer on the mechanicsProvide an end-to-end exampleAnd cover the different approaches to gherkin feature writingSound good?OK – let’s get started
  2. Why do Acceptance Test Driven Development?Well, [step through pic]It also helps the team work with confidence
  3. #1 – in this case, English#2A common language between the business and the tech teamHelping you understand better what needs to be builtAnd, 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 stuffThey have the power to turn high-level acceptance criteria into specific &amp; actionable acceptance tests (either to be carried out manually, or, with automation)They also engage our brains enabling us to visualize scenarios &amp; 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
  4. So, really, it’s not just about automation, it’s about communication. To bring this point home, here’s a quote from the creator of Cucumber
  5. Okay, let’s change gears and step through the mechanics of CucumberCucumber uses Gherkin which is a universalTo be clear -- Gherkin can be used in other BDD frameworks that use other programming languagesFor our purposes, we’ll be using Cucumber &amp; RubySo, in Cucumber, there is a default folder structure – let’s step through it
  6. Capybara API: https://gist.github.com/428105
  7. Basic example (from end-to-end earlier)
  8. Extend it – there are two additional keywordsBut may be indicative of the need for another scenarioBut your mileage may varyDepends on the readability and if it works for you and the team
  9. The words don’t matter to Cucumber. They should matter to YOU
  10. This seems much more readable – don’t you think?
  11. Helper text – aka User Stories can go here
  12. Freedom to specify data in different ways – e.g. headings down the site, or just specify a listThe pipes’ spacing doesn’t matter to Cucumber