SlideShare a Scribd company logo
1 of 44
Download to read offline
Behavior Driven Development

                                  Cucumber
                                                              with


                                      Brandon Keepers ● Collective idea ● http://opensoul.org




http://flickr.com/photos/nickatkins/527421404/
Feature: Cucumber
  In order to share the love
  As a presenter
  I will demonstrate behavior driven development with Cucumber

 Scenario: Behavior Driven Development with Cucumber
   Given a desire for higher quality software
   And a tool that executes feature documentation written in plain text
   When you watch this presentation
   Then you will gain an understanding of behavior driven development
   And see examples of behavior driven development with cucumber
   And be equipped to integrate Cucumber into your development process
Quality
1
Quality
meets requirements
Developer


Language
   Client
Developer


Stories
  Client
In order to keep of track movies that I want to see
As a NetFlix customer
I can add movies to a queue




               http://dannorth.net/whats-in-a-story
va l ue p ro p o s i t i o n


In order to keep of track movies that I want to see
As a NetFlix customer
I can add movies to a queue




               http://dannorth.net/whats-in-a-story
In order to keep of track movies that I want to see
As a NetFlix customer            role
I can add movies to a queue




               http://dannorth.net/whats-in-a-story
In order to keep of track movies that I want to see
As a NetFlix customer
I can add movies to a queue


                             e at u re
                         f

               http://dannorth.net/whats-in-a-story
2
Quality
works as expected
Test Driven
Behavior Driven
Verify
Confidence
Design
Behavior
Testing

Specifying
Cucumber

http://flickr.com/photos/nickatkins/527421404/
rbehave

rSpec Story Runner

  Cucumber
http://github.com/aslakhellesoy/cucumber
$ gem install cucumber
Rakefile

require 'rubygems'
require 'cucumber/rake/task'

Cucumber::Rake::Task.new
$ rake features
Rails
$ ruby script/plugin install 
   git://github.com/aslakhellesoy/cucumber.git 
   git://github.com/brynary/webrat.git 
   git://github.com/dchelimsky/rspec.git 
   git://github.com/dchelimsky/rspec-rails.git

$ ruby script/plugin install 
   git://brandon.local/cucumber 
   git://brandon.local/webrat 
   git://brandon.local/rspec 
   git://brandon.local/rspec-rails
Dependencies


$ gem install term-ansicolor 
   treetop diff-lcs hpricot
$ ruby script/generate cucumber
Feature: Manage companies
  In order to keep track of companies
  A user
  Should be able to manage companies

 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
features/
 companies.feature
 steps/
  company_steps.rb
Given == Setup

Given quot;I am logged inquot; do
  user = Factory(:user)
  visits new_session_path
  fills_in ‘Login’,     :with => user.login
  fills_in ‘Password’, :with => user.password
  clicks_button ‘Login’
end
Given quot;I am logged inquot; do
  user = Factory(:user)
                               f ac t o r y_g i r l
  visits new_session_path
  fills_in ‘Login’,     :with => user.login
  fills_in ‘Password’, :with => user.password
  clicks_button ‘Login’
end

          Factory.sequence(:email) {|n| quot;user#{n}@example.comquot; }
          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
Given quot;I am logged inquot; do
  user = Factory(:user)
  visits new_session_path
  fills_in 'Login',     :with => user.login
  fills_in 'Password', :with => user.password
  clicks_button 'Login'
end

                                            we b rat
When == Change


When quot;I create a new company named $namequot; do |name|
  visits new_company_path
  fills_in 'Name', :with => name
  clicks_button 'Create'
end
When == Change
                                   v a r i a ble


When quot;I create a new company named $namequot; do |name|
  visits new_company_path
  fills_in 'Name', :with => name
  clicks_button 'Create'
end


         When I create a new company named Acme
Then == Outcome


Then quot;I should see that a company named $name existsquot; do |name|
  response.body.should =~ Regexp.new(name)
end
Feature: Manage companies
  In order to keep track of companies
  A user
  Should be able to manage companies

 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

3 steps passsed
Scenario: Paging through leads and rejecting
  Given a company called Apple Corp.
  And a company called Pear Inc.
  And a list for Client A
  And Apple Corp. is a new lead in a list for Client A
  And Pear Inc. is a new lead in a list for Client A
  And I am logged in as a staff member

  When I view the company overview for Apple Corp.
  And I reject Apple Corp.
  And I go to the next lead

  Then I see the company overview for Pear Inc.
Cucumber or RSpec?
Cucumber or RSpec?


 BOTH
http://github.com/bmabey/cucumber-tmbundle/
Feature: Cucumber
  In order to share the love
  As a presenter
  I will demonstrate behavior driven development with Cucumber

  Scenario: Behavior Driven Development with Cucumber
    Given a desire for higher quality software
    And a tool that executes feature documentation written in plain text
    When you watch this presentation
    Then you will gain an understanding of behavior driven development
    And see examples of behavior driven development with cucumber
    And be equipped to integrate Cucumber into your development process

6 steps passed
@bkeepers
github.com/
    brandon
    collectiveidea
opensoul.org
sessions.collectiveidea.com

More Related Content

What's hot

BDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationBDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world application
John Ferguson Smart Limited
 
Behavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile TestingBehavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile Testing
dversaci
 

What's hot (20)

Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
 
BDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationBDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world application
 
BDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVABDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVA
 
Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumber
 
Behavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile TestingBehavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile Testing
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
 
Behavior Driven Development Testing (BDD)
Behavior Driven Development Testing (BDD)Behavior Driven Development Testing (BDD)
Behavior Driven Development Testing (BDD)
 
Behavior Driven Development Pros and Cons
Behavior Driven Development Pros and ConsBehavior Driven Development Pros and Cons
Behavior Driven Development Pros and Cons
 
BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumber
 
Successfully Implementing BDD in an Agile World
Successfully Implementing BDD in an Agile WorldSuccessfully Implementing BDD in an Agile World
Successfully Implementing BDD in an Agile World
 
Cucumber BDD
Cucumber BDDCucumber BDD
Cucumber BDD
 
Behavior Driven Development (BDD)
Behavior Driven Development (BDD)Behavior Driven Development (BDD)
Behavior Driven Development (BDD)
 
Cucumber Tool
Cucumber ToolCucumber Tool
Cucumber Tool
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
 
cucumber harpal.pdf
cucumber harpal.pdfcucumber harpal.pdf
cucumber harpal.pdf
 
Bdd – with cucumber and gherkin
Bdd – with cucumber and gherkinBdd – with cucumber and gherkin
Bdd – with cucumber and gherkin
 
Transforming Your QA and Test Team
Transforming Your QA and Test TeamTransforming Your QA and Test Team
Transforming Your QA and Test Team
 

Similar to Behavior Driven Development with Cucumber

Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructure
Lindsay Holmwood
 
Simple Social Networking with Ruby on Rails
Simple Social Networking with Ruby on RailsSimple Social Networking with Ruby on Rails
Simple Social Networking with Ruby on Rails
jhenry
 

Similar to Behavior Driven Development with Cucumber (20)

Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructure
 
Cucumber: How I Slice It
Cucumber: How I Slice ItCucumber: How I Slice It
Cucumber: How I Slice It
 
Introduce cucumber
Introduce cucumberIntroduce cucumber
Introduce cucumber
 
Double Loop: TDD & BDD Done Right
Double Loop: TDD & BDD Done RightDouble Loop: TDD & BDD Done Right
Double Loop: TDD & BDD Done Right
 
Cucumber & BDD
Cucumber & BDDCucumber & BDD
Cucumber & BDD
 
CUCUMBER - Making BDD Fun
CUCUMBER - Making BDD FunCUCUMBER - Making BDD Fun
CUCUMBER - Making BDD Fun
 
Behat - Drupal South 2018
Behat  - Drupal South 2018Behat  - Drupal South 2018
Behat - Drupal South 2018
 
Behat - human-readable automated testing
Behat - human-readable automated testingBehat - human-readable automated testing
Behat - human-readable automated testing
 
Enabling agile devliery through enabling BDD in PHP projects
Enabling agile devliery through enabling BDD in PHP projectsEnabling agile devliery through enabling BDD in PHP projects
Enabling agile devliery through enabling BDD in PHP projects
 
Behat for writing tests in a stylized way
Behat for writing tests in a stylized wayBehat for writing tests in a stylized way
Behat for writing tests in a stylized way
 
BDD / cucumber /Capybara
BDD / cucumber /CapybaraBDD / cucumber /Capybara
BDD / cucumber /Capybara
 
Behaviour Driven Development
Behaviour Driven DevelopmentBehaviour Driven Development
Behaviour Driven Development
 
Beautiful Java EE - PrettyFaces
Beautiful Java EE - PrettyFacesBeautiful Java EE - PrettyFaces
Beautiful Java EE - PrettyFaces
 
Transformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicaçãoTransformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicação
 
Simple Social Networking with Ruby on Rails
Simple Social Networking with Ruby on RailsSimple Social Networking with Ruby on Rails
Simple Social Networking with Ruby on Rails
 
Mobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B ExperimentsMobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B Experiments
 
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliGetting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
 
Seven Reasons for Code Bloat
Seven Reasons for Code BloatSeven Reasons for Code Bloat
Seven Reasons for Code Bloat
 
Integration Testing in Python
Integration Testing in PythonIntegration Testing in Python
Integration Testing in Python
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
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
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
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...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Behavior Driven Development with Cucumber

  • 1. Behavior Driven Development Cucumber with Brandon Keepers ● Collective idea ● http://opensoul.org http://flickr.com/photos/nickatkins/527421404/
  • 2. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with Cucumber Scenario: Behavior Driven Development with Cucumber Given a desire for higher quality software And a tool that executes feature documentation written in plain text When you watch this presentation Then you will gain an understanding of behavior driven development And see examples of behavior driven development with cucumber And be equipped to integrate Cucumber into your development process
  • 7.
  • 8. In order to keep of track movies that I want to see As a NetFlix customer I can add movies to a queue http://dannorth.net/whats-in-a-story
  • 9. va l ue p ro p o s i t i o n In order to keep of track movies that I want to see As a NetFlix customer I can add movies to a queue http://dannorth.net/whats-in-a-story
  • 10. In order to keep of track movies that I want to see As a NetFlix customer role I can add movies to a queue http://dannorth.net/whats-in-a-story
  • 11. In order to keep of track movies that I want to see As a NetFlix customer I can add movies to a queue e at u re f http://dannorth.net/whats-in-a-story
  • 15.
  • 24. $ gem install cucumber
  • 27. Rails $ ruby script/plugin install git://github.com/aslakhellesoy/cucumber.git git://github.com/brynary/webrat.git git://github.com/dchelimsky/rspec.git git://github.com/dchelimsky/rspec-rails.git $ ruby script/plugin install git://brandon.local/cucumber git://brandon.local/webrat git://brandon.local/rspec git://brandon.local/rspec-rails
  • 28. Dependencies $ gem install term-ansicolor treetop diff-lcs hpricot
  • 30. Feature: Manage companies In order to keep track of companies A user Should be able to manage companies 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
  • 32. Given == Setup Given quot;I am logged inquot; do user = Factory(:user) visits new_session_path fills_in ‘Login’, :with => user.login fills_in ‘Password’, :with => user.password clicks_button ‘Login’ end
  • 33. Given quot;I am logged inquot; do user = Factory(:user) f ac t o r y_g i r l visits new_session_path fills_in ‘Login’, :with => user.login fills_in ‘Password’, :with => user.password clicks_button ‘Login’ end Factory.sequence(:email) {|n| quot;user#{n}@example.comquot; } 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
  • 34. Given quot;I am logged inquot; do user = Factory(:user) visits new_session_path fills_in 'Login', :with => user.login fills_in 'Password', :with => user.password clicks_button 'Login' end we b rat
  • 35. When == Change When quot;I create a new company named $namequot; do |name| visits new_company_path fills_in 'Name', :with => name clicks_button 'Create' end
  • 36. When == Change v a r i a ble When quot;I create a new company named $namequot; do |name| visits new_company_path fills_in 'Name', :with => name clicks_button 'Create' end When I create a new company named Acme
  • 37. Then == Outcome Then quot;I should see that a company named $name existsquot; do |name| response.body.should =~ Regexp.new(name) end
  • 38. Feature: Manage companies In order to keep track of companies A user Should be able to manage companies 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 3 steps passsed
  • 39. Scenario: Paging through leads and rejecting Given a company called Apple Corp. And a company called Pear Inc. And a list for Client A And Apple Corp. is a new lead in a list for Client A And Pear Inc. is a new lead in a list for Client A And I am logged in as a staff member When I view the company overview for Apple Corp. And I reject Apple Corp. And I go to the next lead Then I see the company overview for Pear Inc.
  • 43. Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with Cucumber Scenario: Behavior Driven Development with Cucumber Given a desire for higher quality software And a tool that executes feature documentation written in plain text When you watch this presentation Then you will gain an understanding of behavior driven development And see examples of behavior driven development with cucumber And be equipped to integrate Cucumber into your development process 6 steps passed
  • 44. @bkeepers github.com/ brandon collectiveidea opensoul.org sessions.collectiveidea.com