SlideShare une entreprise Scribd logo
1  sur  27
Our Evolving
Development Framework
Cucumber...

• is not just about testing
• is more than integration testing
• is behaviour driven development
The TDD/BDD Way

• Red
• Green
• Refactor
The Cucumber Way
1. Describe behaviour in plain text
2. Write a step definition in Ruby
3. Run and watch it fail
4. Write code to make the step pass
5. Run again and see the step pass
6. Repeat 2-5 until green like a cuke
7. Repeat 1-6 until the money runs out
Cucumber Terminology
• Features
 • In order to business value,
 • As a role,
 • I want to feature
• Scenarios
 • Given, When, Then
• Step Definitions
Cucumber Setup

•   features directory

•   plain text .feature files

•   step_definitions folder

•   ruby steps files

•   support folder
Feature & Scenario Example
Step Definition Examples
The AMC Way
•   Use Cucumber with:
    •   Webrat (built-in support)
    •   Machinist (fixture replacement)
    •   Ian White’s Pickle (extends Cucumber)
    •   Profiles
    •   Tags
    •   Scenario Outlines
    •   Background
Webrat
• browser simulator
• used by Cucumber by default
• common action step definitions predefined
  using webrat (webrat_steps.rb):
  When I press “Log in”
  Then I should see “Login
  successful”
Machinist

• Fixture replacement
• Allows you to work with real objects:
  User.make
  User.make(:name => ‘Bob’)
Pickle (for objects)
• Uses Machinist, Factory Girl or ActiveRecord
• Provides step definitions for your
  convenience (pickle_steps.rb):
  Given a user exists
  Given a user exists with name:
  “Bob”
Pickle (for paths)

• Extends paths.rb:
  When I go to the users page
  When I go to the user’s
  articles page
Pickle (for email)

• Provides step definitions for your
  convenience (email_steps.rb):
  Given all emails have been
  delivered
  Then 1 email should be
  delivered to “bob@uncle.com”
No New Steps Required
 Scenario: delivering comment notification to one user
    Given a question exists
    And a user exists with name: “Bob”, email:
    “uncle@bob.com”
    When I go to the question's page
    When I fill in "comment[body]" with "My comment"
    And I check “Bob”
    And I press "Add Comment"
    Then 1 email should be delivered to
    “uncle@bob.com”
    And I should see “Comment notification was sent”
Cucumber Profiles

• defined in cucumber.yml
• our current profiles:
 • default
 • sphinx
 • selenium
Default Profile

• uses transactional fixtures (wraps each
  scenario in a database transaction)
• uses webrat
• excludes sphinx and selenium features
Sphinx Profile

• for testing features that use thinking-sphinx
• won’t work with transactional fixtures
• use database cleaner gem instead
• uses webrat
• specifies only sphinx features
Selenium Profile
• useful for testing javascript features
• won’t work with transactional fixtures
• use database cleaner gem instead
• uses selenium webrat configuration
• drives a real browser
• specifies only selenium features
Using Profiles

cucumber
cucumber -p sphinx
cucumber -p selenium
Cucumber Tags
• used to target features and scenarios
• used by profiles:
  cucumber -t sphinx

• use @wip for feature or scenario that you
  are currently working on:
  cucumber -t wip
Cucumber Tags

•   Add directly above
    Feature or Scenario
    keywords

•   Can have more than one
    (comma separated)
Scenario Outlines
Scenario Outlines

• Useful for DRYing up your scenarios when
  only data is changing

• Use Scenario      Outline instead of
  Scenario
Background
Background


• Add context for your scenarios in a single
  feature
And More...
• Some other Cucumber features:
 • Nested steps
 • Hooks
 • Multi-line step arguments
 • Spork and --drb
• Cucumber continues to grow!

Contenu connexe

Tendances

Flexible UI Components for a Multi-Framework World
Flexible UI Components for a Multi-Framework WorldFlexible UI Components for a Multi-Framework World
Flexible UI Components for a Multi-Framework WorldKevin Ball
 
URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5jakemallory
 
PLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfAlfresco Software
 
GIB2021 - Testing with Postman
GIB2021 - Testing with PostmanGIB2021 - Testing with Postman
GIB2021 - Testing with PostmanDaniel Toomey
 
Modern javascript
Modern javascriptModern javascript
Modern javascriptKevin Ball
 
Web Application Frameworks (WAF)
Web Application Frameworks (WAF)Web Application Frameworks (WAF)
Web Application Frameworks (WAF)Ako Kaman
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?Weng Wei
 
Capybara-Webkit
Capybara-WebkitCapybara-Webkit
Capybara-Webkitbostonrb
 
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfAlfresco Software
 
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friendWebcomponents are your frameworks best friend
Webcomponents are your frameworks best friendFilip Bruun Bech-Larsen
 
Ember and SharePoint
Ember and SharePointEmber and SharePoint
Ember and SharePointGreg Hurlman
 
Behaviour driven development present
Behaviour driven development presentBehaviour driven development present
Behaviour driven development presentRaul Panjiyar
 
Stackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for EverybodyStackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for EverybodyCory Forsyth
 
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and PerlAutomating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perlnohuhu
 
Azkaban-en
Azkaban-enAzkaban-en
Azkaban-enwyukawa
 

Tendances (20)

Flexible UI Components for a Multi-Framework World
Flexible UI Components for a Multi-Framework WorldFlexible UI Components for a Multi-Framework World
Flexible UI Components for a Multi-Framework World
 
URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5
 
PLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring Surf
 
GIB2021 - Testing with Postman
GIB2021 - Testing with PostmanGIB2021 - Testing with Postman
GIB2021 - Testing with Postman
 
SpringMVC
SpringMVCSpringMVC
SpringMVC
 
Modern javascript
Modern javascriptModern javascript
Modern javascript
 
Web Application Frameworks (WAF)
Web Application Frameworks (WAF)Web Application Frameworks (WAF)
Web Application Frameworks (WAF)
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
 
Capybara-Webkit
Capybara-WebkitCapybara-Webkit
Capybara-Webkit
 
Hands on Gradle
Hands on GradleHands on Gradle
Hands on Gradle
 
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring Surf
 
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friendWebcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
 
Ember and SharePoint
Ember and SharePointEmber and SharePoint
Ember and SharePoint
 
Behaviour driven development present
Behaviour driven development presentBehaviour driven development present
Behaviour driven development present
 
Stackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for EverybodyStackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for Everybody
 
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and PerlAutomating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
 
Day 8 - jRuby
Day 8 - jRubyDay 8 - jRuby
Day 8 - jRuby
 
Azkaban-en
Azkaban-enAzkaban-en
Azkaban-en
 
Gemboys
GemboysGemboys
Gemboys
 
Frameworks and webcomponents
Frameworks and webcomponentsFrameworks and webcomponents
Frameworks and webcomponents
 

En vedette

Nasdanika WebTest - Modular functional testing of Web and Mobile Applications
Nasdanika WebTest - Modular functional testing of Web and Mobile ApplicationsNasdanika WebTest - Modular functional testing of Web and Mobile Applications
Nasdanika WebTest - Modular functional testing of Web and Mobile ApplicationsPavel Vlasov
 
Selenium Page Objects101
Selenium Page Objects101Selenium Page Objects101
Selenium Page Objects101Adam Goucher
 
MyHeritage - End 2 End testing Infra
MyHeritage - End 2 End testing InfraMyHeritage - End 2 End testing Infra
MyHeritage - End 2 End testing InfraMatanGoren
 
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...Gáspár Nagy
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object patternMichael Palotas
 
Building frameworks over Selenium
Building frameworks over SeleniumBuilding frameworks over Selenium
Building frameworks over SeleniumCristian COȚOI
 
Out of box page object design pattern, java
Out of box page object design pattern, javaOut of box page object design pattern, java
Out of box page object design pattern, javaCOMAQA.BY
 
Page Objects Done Right - selenium conference 2014
Page Objects Done Right - selenium conference 2014Page Objects Done Right - selenium conference 2014
Page Objects Done Right - selenium conference 2014Oren Rubin
 
Write Selenide in Python 15 min
Write Selenide in Python 15 minWrite Selenide in Python 15 min
Write Selenide in Python 15 minIakiv Kramarenko
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questionsKuldeep Pawar
 
Selenium interview questions
Selenium interview questionsSelenium interview questions
Selenium interview questionsgirichinna27
 
Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]Iakiv Kramarenko
 

En vedette (14)

PageObectPattern
PageObectPatternPageObectPattern
PageObectPattern
 
selenium-cucumber
selenium-cucumberselenium-cucumber
selenium-cucumber
 
Nasdanika WebTest - Modular functional testing of Web and Mobile Applications
Nasdanika WebTest - Modular functional testing of Web and Mobile ApplicationsNasdanika WebTest - Modular functional testing of Web and Mobile Applications
Nasdanika WebTest - Modular functional testing of Web and Mobile Applications
 
Selenium Page Objects101
Selenium Page Objects101Selenium Page Objects101
Selenium Page Objects101
 
MyHeritage - End 2 End testing Infra
MyHeritage - End 2 End testing InfraMyHeritage - End 2 End testing Infra
MyHeritage - End 2 End testing Infra
 
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object pattern
 
Building frameworks over Selenium
Building frameworks over SeleniumBuilding frameworks over Selenium
Building frameworks over Selenium
 
Out of box page object design pattern, java
Out of box page object design pattern, javaOut of box page object design pattern, java
Out of box page object design pattern, java
 
Page Objects Done Right - selenium conference 2014
Page Objects Done Right - selenium conference 2014Page Objects Done Right - selenium conference 2014
Page Objects Done Right - selenium conference 2014
 
Write Selenide in Python 15 min
Write Selenide in Python 15 minWrite Selenide in Python 15 min
Write Selenide in Python 15 min
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questions
 
Selenium interview questions
Selenium interview questionsSelenium interview questions
Selenium interview questions
 
Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]
 

Similaire à Cucumber

Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015Andrew Krug
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflowTomas Doran
 
Acceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmAcceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmChristopher Bartling
 
Automated Acceptance Testing from Scratch
Automated Acceptance Testing from ScratchAutomated Acceptance Testing from Scratch
Automated Acceptance Testing from ScratchExcella
 
Getting started with dev tools (atl)
Getting started with dev tools (atl)Getting started with dev tools (atl)
Getting started with dev tools (atl)Thinkful
 
Introduction to cypress in Angular (Chinese)
Introduction to cypress in Angular (Chinese)Introduction to cypress in Angular (Chinese)
Introduction to cypress in Angular (Chinese)Hong Tat Yew
 
Streams API (Web Engines Hackfest 2015)
Streams API (Web Engines Hackfest 2015)Streams API (Web Engines Hackfest 2015)
Streams API (Web Engines Hackfest 2015)Igalia
 
Getting your mobile test automation process in place - using Cucumber and Cal...
Getting your mobile test automation process in place - using Cucumber and Cal...Getting your mobile test automation process in place - using Cucumber and Cal...
Getting your mobile test automation process in place - using Cucumber and Cal...Niels Frydenholm
 
SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!Ben Steinhauser
 
Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)Daniel Friedman
 
Rails 5 subjective overview
Rails 5 subjective overviewRails 5 subjective overview
Rails 5 subjective overviewJan Berdajs
 
Lessons Learnt in 2009
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009pratiknaik
 
Continuous Integration, the minimum viable product
Continuous Integration, the minimum viable productContinuous Integration, the minimum viable product
Continuous Integration, the minimum viable productJulian Simpson
 
Webdriver io presentation
Webdriver io presentationWebdriver io presentation
Webdriver io presentationJoão Nabais
 

Similaire à Cucumber (20)

Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015
 
Cucumber
CucumberCucumber
Cucumber
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
 
Acceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmAcceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvm
 
Automated Acceptance Testing from Scratch
Automated Acceptance Testing from ScratchAutomated Acceptance Testing from Scratch
Automated Acceptance Testing from Scratch
 
Getting started with dev tools (atl)
Getting started with dev tools (atl)Getting started with dev tools (atl)
Getting started with dev tools (atl)
 
Unit4wt
Unit4wtUnit4wt
Unit4wt
 
Unit4wt
Unit4wtUnit4wt
Unit4wt
 
Introduction to cypress in Angular (Chinese)
Introduction to cypress in Angular (Chinese)Introduction to cypress in Angular (Chinese)
Introduction to cypress in Angular (Chinese)
 
Cucumber, Cuke4Duke, and Groovy
Cucumber, Cuke4Duke, and GroovyCucumber, Cuke4Duke, and Groovy
Cucumber, Cuke4Duke, and Groovy
 
Streams API (Web Engines Hackfest 2015)
Streams API (Web Engines Hackfest 2015)Streams API (Web Engines Hackfest 2015)
Streams API (Web Engines Hackfest 2015)
 
Getting your mobile test automation process in place - using Cucumber and Cal...
Getting your mobile test automation process in place - using Cucumber and Cal...Getting your mobile test automation process in place - using Cucumber and Cal...
Getting your mobile test automation process in place - using Cucumber and Cal...
 
SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!
 
Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)
 
Rails 5 subjective overview
Rails 5 subjective overviewRails 5 subjective overview
Rails 5 subjective overview
 
Automation in Drupal
Automation in DrupalAutomation in Drupal
Automation in Drupal
 
Lessons Learnt in 2009
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009
 
Continuous Integration, the minimum viable product
Continuous Integration, the minimum viable productContinuous Integration, the minimum viable product
Continuous Integration, the minimum viable product
 
Webdriver io presentation
Webdriver io presentationWebdriver io presentation
Webdriver io presentation
 

Cucumber

  • 2. Cucumber... • is not just about testing • is more than integration testing • is behaviour driven development
  • 3. The TDD/BDD Way • Red • Green • Refactor
  • 4. The Cucumber Way 1. Describe behaviour in plain text 2. Write a step definition in Ruby 3. Run and watch it fail 4. Write code to make the step pass 5. Run again and see the step pass 6. Repeat 2-5 until green like a cuke 7. Repeat 1-6 until the money runs out
  • 5. Cucumber Terminology • Features • In order to business value, • As a role, • I want to feature • Scenarios • Given, When, Then • Step Definitions
  • 6. Cucumber Setup • features directory • plain text .feature files • step_definitions folder • ruby steps files • support folder
  • 9. The AMC Way • Use Cucumber with: • Webrat (built-in support) • Machinist (fixture replacement) • Ian White’s Pickle (extends Cucumber) • Profiles • Tags • Scenario Outlines • Background
  • 10. Webrat • browser simulator • used by Cucumber by default • common action step definitions predefined using webrat (webrat_steps.rb): When I press “Log in” Then I should see “Login successful”
  • 11. Machinist • Fixture replacement • Allows you to work with real objects: User.make User.make(:name => ‘Bob’)
  • 12. Pickle (for objects) • Uses Machinist, Factory Girl or ActiveRecord • Provides step definitions for your convenience (pickle_steps.rb): Given a user exists Given a user exists with name: “Bob”
  • 13. Pickle (for paths) • Extends paths.rb: When I go to the users page When I go to the user’s articles page
  • 14. Pickle (for email) • Provides step definitions for your convenience (email_steps.rb): Given all emails have been delivered Then 1 email should be delivered to “bob@uncle.com”
  • 15. No New Steps Required Scenario: delivering comment notification to one user Given a question exists And a user exists with name: “Bob”, email: “uncle@bob.com” When I go to the question's page When I fill in "comment[body]" with "My comment" And I check “Bob” And I press "Add Comment" Then 1 email should be delivered to “uncle@bob.com” And I should see “Comment notification was sent”
  • 16. Cucumber Profiles • defined in cucumber.yml • our current profiles: • default • sphinx • selenium
  • 17. Default Profile • uses transactional fixtures (wraps each scenario in a database transaction) • uses webrat • excludes sphinx and selenium features
  • 18. Sphinx Profile • for testing features that use thinking-sphinx • won’t work with transactional fixtures • use database cleaner gem instead • uses webrat • specifies only sphinx features
  • 19. Selenium Profile • useful for testing javascript features • won’t work with transactional fixtures • use database cleaner gem instead • uses selenium webrat configuration • drives a real browser • specifies only selenium features
  • 20. Using Profiles cucumber cucumber -p sphinx cucumber -p selenium
  • 21. Cucumber Tags • used to target features and scenarios • used by profiles: cucumber -t sphinx • use @wip for feature or scenario that you are currently working on: cucumber -t wip
  • 22. Cucumber Tags • Add directly above Feature or Scenario keywords • Can have more than one (comma separated)
  • 24. Scenario Outlines • Useful for DRYing up your scenarios when only data is changing • Use Scenario Outline instead of Scenario
  • 26. Background • Add context for your scenarios in a single feature
  • 27. And More... • Some other Cucumber features: • Nested steps • Hooks • Multi-line step arguments • Spork and --drb • Cucumber continues to grow!

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n