SlideShare a Scribd company logo
Frank Duan
Kinesis
2010
 Introduction to BDD
 Introduction to Cucumber
 Stories and Cucumber features
 Building Cucumber Scenarios and Steps
 Tools
 Slicing Cucumber
 Cucumber Catalyst
FAIL
“I believe that the hardest part of software projects, the
most common source of project failure, is
communication with the customers and users of that
software.
By providing a clear yet precise language to deal with
domains, a DSL can help improve this
communication.”
Martin Fowler
 To meet requirement
 To guarantee quality
verify confidence Design Behaviour
GAP
Bdd, cucumber and freinds
 Outside-In
Bdd, cucumber and freinds
Bdd, cucumber and freinds
Bdd, cucumber and freinds
 Feature
Bdd, cucumber and freinds
 Scenario
Scenario: title
Given [Context]
And [More Context]
When [Action]
And [Other Action]
Then [Expected Outcome]
But [Unexpected Outcome]
Bdd, cucumber and freinds
 A story
 Token for Conversation
 Meet Gherkin
Scenario: search by director
Given the store has movies directed by “Steven
Spielberg”
When I search for “Steven Spielberg”
Then I should see all of the movies directed by “Steven
Spielberg”
 Meet Advanced Gherkin –TABLE
Scenario: search by director
Given the following movies are in stock:
| Title | Director | Year |
| Jaws | Steven Spielberg | 1975 |
| Star Wars | George Lucas | 1975 |
| Dawn of the Dead | George Romero | 1978 |
| E.T. | Steven Spielberg | 1982 |
When I search for "Spielberg" under "Director"
Then I should see the following table:
| Title | Director | Year |
| Jaws | Steven Spielberg | 1975 |
| E.T. | Steven Spielberg | 1982 |
 Meet Advanced Gherkin –Multi-Line String
Scenario: register successfully
Given I am on on the registration page
When I sign up as "Jojo Binks"
Then I should receive the following email:
"""
Thanks for signing up Jojo!
Important information about here.
"""
 Meet Advanced Gherkin –Scenario Outlines
Scenario Outline: search by director
Given the following movies are in stock:
| Title | Director | Year |
| Jaws | Steven Spielberg | 1975 |
| Star Wars | George Lucas | 1975 |
| Dawn of the Dead | George Romero | 1978 |
| E.T. | Steven Spielberg | 1982 |
When I search for "<Director Query>" under "Director"
Then I the search results should be "<Search Results>"
Examples:
| Director Query | Search Results |
| Steve | E.T., Jaws |
| George | Dawn of the Dead, Star Wars |
| Lucas | Star Wars |
 Building step definition (Example)
Scenario: Create a new company
Given I am logged in
When I create a new company named Acme
Then I should see that a company named Acme exists
 Building step definition – Given
 Given == Setup
Given "I am logged in" do
user = Factory(:user)
visits new_session_path
fills_in ‘Login’, :with => user.login
fills_in ‘Password’, :with => user.password
clicks_button ‘Login’
end
 Building step definition – When
 When == Change
When "I create a new company named $name" do
|name|
visits new_company_path
fills_in 'Name', :with => name
clicks_button 'Create'
end
 Building step definition – Then
 Then == Outcome
Then "I should see that a company named $name exists"
do |name|
response.body.should =~ Regexp.new(name)
end
 Hooks – Before and After
 Generic hooks or hooks by tags
 Background
 Adpating rspec DSL for validation
 DOESN’T adpate rspec mock module
 Use factory_girl instead
 factory_girl: load data into database for test
Given "I am logged in" do
user = Factory(:user)
visits new_session_path
fills_in ‘Login’, :with => user.login
fills_in ‘Password’, :with =>
user.password
clicks_button ‘Login’
end Factory.sequence(:email) {|n| "user#{n}@example.com" }
Factory.define :user do |user|
user.name 'User'
user.email { Factory.next(:email) }
user.login {|u| u.email }
user.password 'password'
user.password_confirmation 'password'
end
 Simulating or drive Browsers
 Feature on Javascript test
 Flexibility on switching drivers to achieve different test
demand
 Flexibility on switching between css and xpath selector
 Covering most of the popular browser driving
 Remote calling (for IE test on VM)
 Highlight keywords in Gherkin
 Autocomplete by hotkey
 Run by hotkey and present visual report
 A DRb server for testing frameworks (RSpec /
Cucumber currently) that forks before each run to
ensure a clean testing state.
 Soren knows all about that : s
 Lazy coverage-aware running of Cucumber acceptance
tests
 Run a scenario if it needs to
 Distributed testing framework
 Spread your tests over processors and/or multiple
machines to test your code faster
 Don’t force structure
 Avoid Noise!
 Avoid Inconsistency
 Balance Abstraction
 Building step abstraction from steps
 Tagging
 Tagging for focused testing
 Tagging for categorizing test by purpose and environs
 Tagging for loading capybara configuration
 Slow builds are the enemy of continuous integration
 Reuse – Spork, Cucover
 Run Just Enough Tests
 Slicing Features with tags
 Just enough Database and try NullDB
 Distributed testing - hydra
 The Rspec Book
 http://www.slideshare.net/josephwilk/rocket-fuelled-
cucumbers
 http://www.slideshare.net/bkeepers/behavior-driven-
development-with-cucumber-presentation
 http://www.slideshare.net/josephwilk/cucumbered
 http://www.slideshare.net/bmabey/cucumber-
automating-the-requirements-language-you-already-
speak
Thanks for your patience

More Related Content

PPTX
CucumberSeleniumWD
PPTX
CUCUMBER - Making BDD Fun
PDF
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
PDF
Behaviour driven infrastructure
PDF
RSpec best practice - avoid using before and let
PDF
I put on my mink and wizard behat (talk)
PDF
 Making a Cucumber layer cake: Separation of concerns in the idealized test s...
PPT
Code Quality Practice and Tools
CucumberSeleniumWD
CUCUMBER - Making BDD Fun
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
Behaviour driven infrastructure
RSpec best practice - avoid using before and let
I put on my mink and wizard behat (talk)
 Making a Cucumber layer cake: Separation of concerns in the idealized test s...
Code Quality Practice and Tools

Similar to Bdd, cucumber and freinds (20)

PDF
Javascript testing should be awesome
PDF
I put on my mink and wizard behat
PDF
Software Testing
PDF
End to-end testing from rookie to pro
PDF
I put on my mink and wizard behat - Confoo Canada
PDF
David Nuescheler: Igniting CQ 5.3: What's New and Roadmap
PDF
UI Testing
PDF
Continuous Deployment at Scale, Baltic DevOps 2016
PPTX
One Click Provisioning With Enterprise Manager 12c
PDF
Continuous Deployment at Scale, Rootconf 2016
PPTX
PDF
Paris Web - Javascript as a programming language
PDF
Continuous Deployment at Scale, PHPConfAsia 2016
PDF
Behavioral Driven Development
PDF
Automated Testing with Ruby
PPT
Behavior Driven Development by Example
PPTX
Java script unit testing
PDF
Jozef Ve Providing Scalability for Pirates, Lizards and Zombies at #DOXLON
PDF
Drupal 7 ci and testing
PDF
How EVERFI Moved from No Automation to Continuous Test Generation in 9 Months
Javascript testing should be awesome
I put on my mink and wizard behat
Software Testing
End to-end testing from rookie to pro
I put on my mink and wizard behat - Confoo Canada
David Nuescheler: Igniting CQ 5.3: What's New and Roadmap
UI Testing
Continuous Deployment at Scale, Baltic DevOps 2016
One Click Provisioning With Enterprise Manager 12c
Continuous Deployment at Scale, Rootconf 2016
Paris Web - Javascript as a programming language
Continuous Deployment at Scale, PHPConfAsia 2016
Behavioral Driven Development
Automated Testing with Ruby
Behavior Driven Development by Example
Java script unit testing
Jozef Ve Providing Scalability for Pirates, Lizards and Zombies at #DOXLON
Drupal 7 ci and testing
How EVERFI Moved from No Automation to Continuous Test Generation in 9 Months
Ad

Recently uploaded (20)

PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PDF
Getting Started with Data Integration: FME Form 101
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
DOCX
search engine optimization ppt fir known well about this
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPT
What is a Computer? Input Devices /output devices
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPTX
Modernising the Digital Integration Hub
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
August Patch Tuesday
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
A review of recent deep learning applications in wood surface defect identifi...
Web Crawler for Trend Tracking Gen Z Insights.pptx
Getting Started with Data Integration: FME Form 101
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Taming the Chaos: How to Turn Unstructured Data into Decisions
search engine optimization ppt fir known well about this
Final SEM Unit 1 for mit wpu at pune .pptx
Tartificialntelligence_presentation.pptx
1 - Historical Antecedents, Social Consideration.pdf
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
What is a Computer? Input Devices /output devices
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Benefits of Physical activity for teenagers.pptx
A novel scalable deep ensemble learning framework for big data classification...
Group 1 Presentation -Planning and Decision Making .pptx
sustainability-14-14877-v2.pddhzftheheeeee
Modernising the Digital Integration Hub
Assigned Numbers - 2025 - Bluetooth® Document
August Patch Tuesday
WOOl fibre morphology and structure.pdf for textiles
A review of recent deep learning applications in wood surface defect identifi...
Ad

Bdd, cucumber and freinds

  • 2.  Introduction to BDD  Introduction to Cucumber  Stories and Cucumber features  Building Cucumber Scenarios and Steps  Tools  Slicing Cucumber  Cucumber Catalyst
  • 4. “I believe that the hardest part of software projects, the most common source of project failure, is communication with the customers and users of that software. By providing a clear yet precise language to deal with domains, a DSL can help improve this communication.” Martin Fowler
  • 5.  To meet requirement  To guarantee quality verify confidence Design Behaviour
  • 6. GAP
  • 14.  Scenario Scenario: title Given [Context] And [More Context] When [Action] And [Other Action] Then [Expected Outcome] But [Unexpected Outcome]
  • 17.  Token for Conversation
  • 19. Scenario: search by director Given the store has movies directed by “Steven Spielberg” When I search for “Steven Spielberg” Then I should see all of the movies directed by “Steven Spielberg”
  • 20.  Meet Advanced Gherkin –TABLE Scenario: search by director Given the following movies are in stock: | Title | Director | Year | | Jaws | Steven Spielberg | 1975 | | Star Wars | George Lucas | 1975 | | Dawn of the Dead | George Romero | 1978 | | E.T. | Steven Spielberg | 1982 | When I search for "Spielberg" under "Director" Then I should see the following table: | Title | Director | Year | | Jaws | Steven Spielberg | 1975 | | E.T. | Steven Spielberg | 1982 |
  • 21.  Meet Advanced Gherkin –Multi-Line String Scenario: register successfully Given I am on on the registration page When I sign up as "Jojo Binks" Then I should receive the following email: """ Thanks for signing up Jojo! Important information about here. """
  • 22.  Meet Advanced Gherkin –Scenario Outlines Scenario Outline: search by director Given the following movies are in stock: | Title | Director | Year | | Jaws | Steven Spielberg | 1975 | | Star Wars | George Lucas | 1975 | | Dawn of the Dead | George Romero | 1978 | | E.T. | Steven Spielberg | 1982 | When I search for "<Director Query>" under "Director" Then I the search results should be "<Search Results>" Examples: | Director Query | Search Results | | Steve | E.T., Jaws | | George | Dawn of the Dead, Star Wars | | Lucas | Star Wars |
  • 23.  Building step definition (Example) Scenario: Create a new company Given I am logged in When I create a new company named Acme Then I should see that a company named Acme exists
  • 24.  Building step definition – Given  Given == Setup Given "I am logged in" do user = Factory(:user) visits new_session_path fills_in ‘Login’, :with => user.login fills_in ‘Password’, :with => user.password clicks_button ‘Login’ end
  • 25.  Building step definition – When  When == Change When "I create a new company named $name" do |name| visits new_company_path fills_in 'Name', :with => name clicks_button 'Create' end
  • 26.  Building step definition – Then  Then == Outcome Then "I should see that a company named $name exists" do |name| response.body.should =~ Regexp.new(name) end
  • 27.  Hooks – Before and After  Generic hooks or hooks by tags  Background
  • 28.  Adpating rspec DSL for validation  DOESN’T adpate rspec mock module  Use factory_girl instead
  • 29.  factory_girl: load data into database for test Given "I am logged in" do user = Factory(:user) visits new_session_path fills_in ‘Login’, :with => user.login fills_in ‘Password’, :with => user.password clicks_button ‘Login’ end Factory.sequence(:email) {|n| "user#{n}@example.com" } Factory.define :user do |user| user.name 'User' user.email { Factory.next(:email) } user.login {|u| u.email } user.password 'password' user.password_confirmation 'password' end
  • 30.  Simulating or drive Browsers  Feature on Javascript test  Flexibility on switching drivers to achieve different test demand  Flexibility on switching between css and xpath selector  Covering most of the popular browser driving  Remote calling (for IE test on VM)
  • 31.  Highlight keywords in Gherkin  Autocomplete by hotkey  Run by hotkey and present visual report
  • 32.  A DRb server for testing frameworks (RSpec / Cucumber currently) that forks before each run to ensure a clean testing state.
  • 33.  Soren knows all about that : s
  • 34.  Lazy coverage-aware running of Cucumber acceptance tests  Run a scenario if it needs to
  • 35.  Distributed testing framework  Spread your tests over processors and/or multiple machines to test your code faster
  • 36.  Don’t force structure  Avoid Noise!  Avoid Inconsistency  Balance Abstraction
  • 37.  Building step abstraction from steps  Tagging  Tagging for focused testing  Tagging for categorizing test by purpose and environs  Tagging for loading capybara configuration
  • 38.  Slow builds are the enemy of continuous integration  Reuse – Spork, Cucover  Run Just Enough Tests  Slicing Features with tags  Just enough Database and try NullDB  Distributed testing - hydra
  • 39.  The Rspec Book  http://www.slideshare.net/josephwilk/rocket-fuelled- cucumbers  http://www.slideshare.net/bkeepers/behavior-driven- development-with-cucumber-presentation  http://www.slideshare.net/josephwilk/cucumbered  http://www.slideshare.net/bmabey/cucumber- automating-the-requirements-language-you-already- speak
  • 40. Thanks for your patience