SlideShare ist ein Scribd-Unternehmen logo
1 von 54
Downloaden Sie, um offline zu lesen
Behaviour-driven
development with
   Cucumber
        Kerry Buckley
  BT DevCon6, 4 February 2013


       http://www.ïŹ‚ickr.com/photos/yogendra174/4665988849
A developer tool for
end-to-end testing of
ruby web applications
A developer tool for
end-to-end testing of
ruby web applications
 LIE
Basics
Feature: DevCon talk
  In order to fill the DevCon6 schedule
  As a Cucumber user
  I want to talk about BDD with Cucumber

  Scenario: "BDD with Cucumber" talk
    Given I have managed to prepare a talk
    And there are people there to hear it
    When I give the talk
    Then the audience should learn something
Feature: DevCon talk
  In order to fill the DevCon6 schedule
  As a Cucumber user
  I want to talk about BDD with Cucumber

  Scenario: "BDD with Cucumber" talk
    Given I have managed to prepare a talk
    And there are people there to hear it
    When I give the talk
    Then the audience should learn something
Feature: DevCon talk
  In order to fill the DevCon6 schedule
  As a Cucumber user
  I want to talk about BDD with Cucumber

  Scenario: "BDD with Cucumber" talk
    Given I have managed to prepare a talk
    And there are people there to hear it
    When I give the talk
    Then the audience should learn something
Feature: DevCon talk
  In order to fill the DevCon6 schedule
  As a Cucumber user
  I want to talk about BDD with Cucumber

  Scenario: "BDD with Cucumber" talk
    Given I have managed to prepare a talk
    And there are people there to hear it
    When I give the talk
    Then the audience should learn something
Feature: DevCon talk
  In order to fill the DevCon6 schedule
  As a Cucumber user
  I want to talk about BDD with Cucumber

  Scenario: "BDD with Cucumber" talk
    Given I have managed to prepare a talk
    And there are people there to hear it
    When I give the talk
    Then the audience should learn something
Feature: Withdraw cash from account

  Scenario: Successful withdrawal
    Given I have ÂŁ100 in my account
    When I request a withdrawal of ÂŁ20
    Then I should receive ÂŁ20
    And my balance should be ÂŁ80
$ cucumber withdraw_cash.feature
Feature: Withdraw cash from account

  Scenario: Successful withdrawal        #   withdraw_cash.feature:3
    Given I have ÂŁ100 in my account      #   withdraw_cash.feature:4
    When I request a withdrawal of ÂŁ20   #   withdraw_cash.feature:5
    Then I should receive ÂŁ20            #   withdraw_cash.feature:6
    And my balance should be ÂŁ80         #   withdraw_cash.feature:7

1 scenario (1 undefined)
4 steps (4 undefined)
0m0.002s

You can implement step definitions for undefined steps with these snippets:

Given /^I have ÂŁ(d+) in my account$/ do |arg1|
  pending # express the regexp above with the code you wish you had
end

...
Scenario: Successful login
  Given a user "Fred" with password "secret"
  When I go to the login page
  And I fill in "User name" with "Fred"
  And I fill in "Password" with "secret"
  And I press "Log in"
  Then I should see "Welcome, Fred"
Scenario: Adding a CaaS Linux Service in a production (or test) environment
  Given a fred production environment exists
  And I am on the last deployment page

  When I select "CaaS Linux Service" from "Add a new"
  And I press "Add service"
  And I fill in the following:
    | Role                           | FTP Server |
    | Application Installed Software | None       |
  And I select "SC3 (redside)" from "Security Domain"
  And I select "2" from "Virtual CPUs"
  And I select "2" from "Virtual Memory"
  And I select "OEL 5u6 32bit" from "Operating System"
  And I select "None" from "MaaS(EMB) MQ Client"
  And I select "None" from "Oracle Client"
  And I check "Netbackup Client"
  And I check "XFB Client"
  And I check "BT Hunter Client"
  And I check "BTBPTM Client"
  And I check "Web Tier"
  And I press "Save"

  Then I should be on the last deployment page
  And I should see "Service saved"
  And I should see ...
Scenario: Successful login
  Given a user "Fred" with password "secret"
  When I go to the login page
  And I fill in "User name" with "Fred"
  And I fill in "Password" with "secret"
  And I press "Log in"
  Then I should see "Welcome, Fred"
Scenario: User is greeted upon login
  Given the user "Fred" has an account
  When he logs in
  Then he should see "Welcome, Fred"
Given /^the user "(.*?)" has an account$/ do |name|
  @user = User.find_or_create_by_name name, password: "secret"
end

When /^he logs in$/ do
  visit "/login"
  fill_in "User name", with: @user.name
  fill_in "Password", with: @user.password
  click_button "Log in"
end

Then /^he should see "(.*?)"$/ do |text|
  page.should have_content(text)
end
Scenario: User is greeted upon login
  Given the user "Fred" has an account
  When he logs in
  Then he should see "Welcome, Fred"


Scenario: Secure pages require login
  When I visit a secure page as a guest
  Then I should be asked to log in

 When I log in with a valid account
 Then I should see the secure page
Feature: My awesome system

 Scenario: Using the system
   Given the system exists
   When I use it
   Then everything should work perfectly
A developer tool for
end-to-end testing
of web applications
A developer tool for
      LIE

end-to-end testing
of web applications
Scenario: create a dir
  Given a directory named "foo/bar"
  When I run `file foo/bar`
  Then the stdout should contain "foo/bar: directory"

Scenario: create a file
  Given a file named "foo/bar/example.txt" with:
    """
    hello world
    """
  When I run `cat foo/bar/example.txt`
  Then the output should contain exactly "hello world"
A tool for end-to-
end testing of web
   applications
A tool for end-to-
end testing of web
                 LIE
   applications
More feature
  
 er 

 features
Feature: Posting messages to friends

 Scenario: Posting a text message
   Given I am logged in
   When I post a text message
   Then my friends should see my message

 Scenario: Posting a photo
   Given I am logged in
   When I post a photo
   Then my friends should see a thumbnail of my photo
   And clicking the thumbnail should show the photo
Feature: Posting messages to friends

 Scenario: Posting a text message
   Given I am logged in
   When I post a text message
   Then my friends should see my message

 Scenario: Posting a photo
   Given I am logged in
   When I post a photo
   Then my friends should see a thumbnail of my photo
   And clicking the thumbnail should show the photo
Feature: Posting messages to friends
  Background:
    Given I am logged in

 Scenario: Posting a text message
   When I post a text message
   Then my friends should see my message

 Scenario: Posting a photo
   When I post a photo
   Then my friends should see a thumbnail of my photo
   And clicking the thumbnail should show the photo
Scenario:
  When I add 1 widget to my order
  And I add 5 doodahs to my order
  And I add 2 thingummies to my order
  Then my basket total should be ÂŁ12.34
Scenario:
  When I add the   following to my order:
    | Quantity |   Item      |
    | 1        |   widget    |
    | 5        |   doodah    |
    | 2        |   thingummy |
  Then my basket   total should be ÂŁ12.34
Scenario: Simple addition
  When I calculate 2 + 2
  Then the answer should be 4

 When I calculate 10 + 5
 Then the answer should be 15

Scenario: Simple multiplication
  When I calculate 2 * 2
  Then the answer should be 4

 When I calculate 6 * 7
 Then the answer should be 42
Scenario Outline: Simple arithmetic
  When I calculate <first> <operation> <second>
  Then the answer should be <answer>

 Examples:
   | first   |   operation   |   second   |   answer   |
   | 2       |   +           |   2        |   4        |
   | 10      |   +           |   5        |   15       |
   | 2       |   *           |   2        |   4        |
   | 6       |   *           |   7        |   42       |
http://www.ïŹ‚ickr.com/photos/yogendra174/4665988849
# language: fr
Fonctionnalité: Addition
  Afin de financer mon bonus avec l'argent des pigeons
  En tant que trader
  Je souhaite pouvoir additionner 2 chiffres

 Plan du Scénario: Addition de produits dérivés
   Soit une calculatrice
   Etant donné qu'on tape <a>
   Et qu'on tape <b>
   Lorsqu'on tape additionner
   Alors le rĂ©sultat doit ĂȘtre <somme>

 Exemples:
   | a | b | somme |
   | 2 | 2 | 4     |
   | 2 | 3 | 5     |
# language: es
CaracterĂ­stica: adiciĂłn
  Para evitar hacer errores tontos
  Como un matemĂĄtico idiota
  Quiero saber la suma de los nĂșmeros

 Esquema del escenario: Sumar dos nĂșmeros
   Dado que he introducido <entrada_1> en la calculadora
   Y que he introducido <entrada_2> en la calculadora
   Cuando oprimo el <botĂłn>
   Entonces el resultado debe ser <resultado> en la pantalla

 Ejemplos:
   | entrada_1   |   entrada_2   |   botĂłn   |   resultado   |
   | 20          |   30          |   add     |   50          |
   | 2           |   5           |   add     |   7           |
   | 0           |   40          |   add     |   40          |
# language: de
FunktionalitÀt: Addition
  Um dumme Fehler zu vermeiden
  möchte ich als Matheidiot
  die Summe zweier Zahlen gesagt bekommen

 Szenariogrundriss: Zwei Zahlen hinzufĂŒgen
   Angenommen ich habe <Eingabe_1> in den Taschenrechner eingegeben
   Und ich habe <Eingabe_2> in den Taschenrechner eingegeben
   Wenn ich <Knopf> drĂŒcke
   Dann sollte das Ergebniss auf dem Bildschirm <Ausgabe> sein

 Beispiele:
   | Eingabe_1   |   Eingabe_2   |   Knopf   |   Ausgabe   |
   | 20          |   30          |   add     |   50        |
   | 2           |   5           |   add     |   7         |
   | 0           |   40          |   add     |   40        |
# language: en-lol
OH HAI: STUFFING

 MISHUN:   CUCUMBR
   I CAN   HAZ IN TEH BEGINNIN 3 CUCUMBRZ
   WEN I   EAT 2 CUCUMBRZ
   DEN I   HAS 2 CUCUMBERZ IN MAH BELLY
   AN IN   TEH END 1 CUCUMBRZ KTHXBAI
Getting the most
out of Cucumber
http://www.ïŹ‚ickr.com/photos/oskay/2156888497
Given /^the user "(.*?)" has an account$/ do |name|
  @user = User.find_or_create_by_name name, password: "secret"
end

Given /^a logged-in user$/ do
  @user = User.find_or_create_by_name "Fred", password: "secret"
  visit "/login"
  fill_in "User name", :with => @user.name
  fill_in "Password", :with => @user.password
  click_button "Log in"
end

When /^he logs in$/ do
  visit "/login"
  fill_in "User name", with: @user.name
  fill_in "Password", with: @user.password
  click_button "Log in"
end

Then /^he should see "(.*?)"$/ do |text|
  page.should have_content(text)
end
Given /^the user "(.*?)" has an account$/ do |name|
  @user = User.find_or_create_by_name name, password: "secret"
end

Given /^a logged-in user$/ do
  @user = User.find_or_create_by_name "Fred", password: "secret"
  visit "/login"
  fill_in "User name", :with => @user.name
  fill_in "Password", :with => @user.password
  click_button "Log in"
end

When /^he logs in$/ do
  visit "/login"
  fill_in "User name", with: @user.name
  fill_in "Password", with: @user.password
  click_button "Log in"
end

Then /^he should see "(.*?)"$/ do |text|
  page.should have_content(text)
end
module LoginSteps
  def login(name, password)
    visit "/login"
    fill_in "User name", with: name
    fill_in "Password", with: password
    click_button "Log in"
  end
end

World(LoginSteps)

Given /^a logged in user$/ do
  @user = User.find_or_create_by_name name, password: "secret"
  login(@user.name, @user.password)
end

When /^he logs in$/ do
  login(@user.name, @user.password)
end
http://tooky.co.uk/2013/01/18/cucumber-and-full-stack-testing.html
http://blog.mattwynne.net/2012/05/31/hexagonal-rails-objects-values-and-hexagons/
A tool for
end-to-end testing
  of applications
A tool for
end-to-end testing
     LIE
  of applications
A tool for testing
  applications
A tool for testingRELY
               TI
  applications
        N
            EN HER
          OT EIT
            UE
         TR
http://www.ïŹ‚ickr.com/photos/elycefeliz/3224486233
Made-up statistics

                        Identifying scenarios
                                 25%
   Automated tests
        35%




                     Agreeing steps
                         40%
$ cucumber talk.feature
Feature: DevCon talk
  In order to fill the DevCon6 schedule
  As a Cucumber user
  I want to talk about BDD with Cucumber

  Scenario: "BDD with Cucumber" talk                # talk.feature:6
    Given I have managed to prepare my talk on time # talk_steps.rb:1
    And there are people there to hear it           # talk_steps.rb:4
    When I give the talk                            # talk_steps.rb:7
    Then the audience should learn something        # talk_steps.rb:10

1 scenario (1 passed)
4 steps (4 passed)
0m0.002s
http://www.ïŹ‚ickr.com/photos/erix/3780828260

Weitere Àhnliche Inhalte

Was ist angesagt?

Implementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberImplementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberTechWell
 
CUCUMBER - Making BDD Fun
CUCUMBER - Making BDD FunCUCUMBER - Making BDD Fun
CUCUMBER - Making BDD FunSQABD
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Storiesrahoulb
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress PluginAndy Stratton
 
Behat - Drupal South 2018
Behat  - Drupal South 2018Behat  - Drupal South 2018
Behat - Drupal South 2018Berend de Boer
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFesttomdale
 
Simplifying Code: Monster to Elegant in 5 Steps
Simplifying Code: Monster to Elegant in 5 StepsSimplifying Code: Monster to Elegant in 5 Steps
Simplifying Code: Monster to Elegant in 5 Stepstutec
 
Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Engine Yard
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
You're Doing It Wrong
You're Doing It WrongYou're Doing It Wrong
You're Doing It Wrongbostonrb
 
Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011dimakovalenko
 
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 LazuliRebecca Eloise Hogg
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsLeticia Rss
 
What you can do In WatiR
What you can do In WatiRWhat you can do In WatiR
What you can do In WatiRWesley Chen
 
Telling Stories With RSpec
Telling Stories With RSpecTelling Stories With RSpec
Telling Stories With RSpecrahoulb
 
watir-webdriver
watir-webdriverwatir-webdriver
watir-webdriverjariba
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin DevelopmentShinichi Nishikawa
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with RubyKeith Pitty
 
Watir web automated tests
Watir web automated testsWatir web automated tests
Watir web automated testsNexle Corporation
 

Was ist angesagt? (20)

Implementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberImplementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using Cucumber
 
CUCUMBER - Making BDD Fun
CUCUMBER - Making BDD FunCUCUMBER - Making BDD Fun
CUCUMBER - Making BDD Fun
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Stories
 
BDD, Behat & Drupal
BDD, Behat & DrupalBDD, Behat & Drupal
BDD, Behat & Drupal
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
Behat - Drupal South 2018
Behat  - Drupal South 2018Behat  - Drupal South 2018
Behat - Drupal South 2018
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
 
Simplifying Code: Monster to Elegant in 5 Steps
Simplifying Code: Monster to Elegant in 5 StepsSimplifying Code: Monster to Elegant in 5 Steps
Simplifying Code: Monster to Elegant in 5 Steps
 
Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
You're Doing It Wrong
You're Doing It WrongYou're Doing It Wrong
You're Doing It Wrong
 
Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011
 
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
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjects
 
What you can do In WatiR
What you can do In WatiRWhat you can do In WatiR
What you can do In WatiR
 
Telling Stories With RSpec
Telling Stories With RSpecTelling Stories With RSpec
Telling Stories With RSpec
 
watir-webdriver
watir-webdriverwatir-webdriver
watir-webdriver
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin Development
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with Ruby
 
Watir web automated tests
Watir web automated testsWatir web automated tests
Watir web automated tests
 

Andere mochten auch

Javasccript MV* frameworks
Javasccript MV* frameworksJavasccript MV* frameworks
Javasccript MV* frameworksKerry Buckley
 
Testing http calls with Webmock and VCR
Testing http calls with Webmock and VCRTesting http calls with Webmock and VCR
Testing http calls with Webmock and VCRKerry Buckley
 
Adastral Park code retreat introduction
Adastral Park code retreat introductionAdastral Park code retreat introduction
Adastral Park code retreat introductionKerry Buckley
 
Single Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance MeetupSingle Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance MeetupEyal Golan
 

Andere mochten auch (7)

Javasccript MV* frameworks
Javasccript MV* frameworksJavasccript MV* frameworks
Javasccript MV* frameworks
 
7li7w devcon5
7li7w devcon57li7w devcon5
7li7w devcon5
 
TDD refresher
TDD refresherTDD refresher
TDD refresher
 
Testing http calls with Webmock and VCR
Testing http calls with Webmock and VCRTesting http calls with Webmock and VCR
Testing http calls with Webmock and VCR
 
Adastral Park code retreat introduction
Adastral Park code retreat introductionAdastral Park code retreat introduction
Adastral Park code retreat introduction
 
Jasmine
JasmineJasmine
Jasmine
 
Single Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance MeetupSingle Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance Meetup
 

Ähnlich wie BDD with cucumber

Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...Aslak HellesĂžy
 
I put on my mink and wizard behat (talk)
I put on my mink and wizard behat (talk)I put on my mink and wizard behat (talk)
I put on my mink and wizard behat (talk)xsist10
 
How React Native Appium and me made each other shine
How React Native Appium and me made each other shineHow React Native Appium and me made each other shine
How React Native Appium and me made each other shineWim Selles
 
I put on my mink and wizard behat
I put on my mink and wizard behatI put on my mink and wizard behat
I put on my mink and wizard behatxsist10
 
The Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt EakinThe Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt EakinQA or the Highway
 
I put on my mink and wizard behat - Confoo Canada
I put on my mink and wizard behat - Confoo CanadaI put on my mink and wizard behat - Confoo Canada
I put on my mink and wizard behat - Confoo Canadaxsist10
 
Behat, Test Driven Framework for BDD by Jeevan Bhushetty
Behat, Test Driven Framework for BDD by Jeevan BhushettyBehat, Test Driven Framework for BDD by Jeevan Bhushetty
Behat, Test Driven Framework for BDD by Jeevan BhushettyAgile Testing Alliance
 
Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)Scott Wlaschin
 
BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumberDaniel Kummer
 
Cucumber
CucumberCucumber
CucumberFarooq Ali
 
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 projectsKonstantin Kudryashov
 
Eventsourcing you-are-doing-it-wrong-vxdparis
Eventsourcing you-are-doing-it-wrong-vxdparisEventsourcing you-are-doing-it-wrong-vxdparis
Eventsourcing you-are-doing-it-wrong-vxdparisDavid Schmitz
 
Cucumbers & Factory Girls
Cucumbers & Factory GirlsCucumbers & Factory Girls
Cucumbers & Factory GirlsTim Lucas
 
Moving away from legacy code with BDD
Moving away from legacy code with BDDMoving away from legacy code with BDD
Moving away from legacy code with BDDKonstantin Kudryashov
 
Gherkin for test automation in agile
Gherkin for test automation in agileGherkin for test automation in agile
Gherkin for test automation in agileViresh Doshi
 
Cucumber & BDD
Cucumber & BDDCucumber & BDD
Cucumber & BDDSam Davarnia
 
BDD - Writing better scenario
BDD - Writing better scenarioBDD - Writing better scenario
BDD - Writing better scenarioArnauld Loyer
 
Software Testing
Software TestingSoftware Testing
Software Testingsuperphly
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++ Bharat Kalia
 
Programming with python
Programming with pythonProgramming with python
Programming with pythonsarogarage
 

Ähnlich wie BDD with cucumber (20)

Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
 
I put on my mink and wizard behat (talk)
I put on my mink and wizard behat (talk)I put on my mink and wizard behat (talk)
I put on my mink and wizard behat (talk)
 
How React Native Appium and me made each other shine
How React Native Appium and me made each other shineHow React Native Appium and me made each other shine
How React Native Appium and me made each other shine
 
I put on my mink and wizard behat
I put on my mink and wizard behatI put on my mink and wizard behat
I put on my mink and wizard behat
 
The Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt EakinThe Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt Eakin
 
I put on my mink and wizard behat - Confoo Canada
I put on my mink and wizard behat - Confoo CanadaI put on my mink and wizard behat - Confoo Canada
I put on my mink and wizard behat - Confoo Canada
 
Behat, Test Driven Framework for BDD by Jeevan Bhushetty
Behat, Test Driven Framework for BDD by Jeevan BhushettyBehat, Test Driven Framework for BDD by Jeevan Bhushetty
Behat, Test Driven Framework for BDD by Jeevan Bhushetty
 
Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)
 
BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumber
 
Cucumber
CucumberCucumber
Cucumber
 
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
 
Eventsourcing you-are-doing-it-wrong-vxdparis
Eventsourcing you-are-doing-it-wrong-vxdparisEventsourcing you-are-doing-it-wrong-vxdparis
Eventsourcing you-are-doing-it-wrong-vxdparis
 
Cucumbers & Factory Girls
Cucumbers & Factory GirlsCucumbers & Factory Girls
Cucumbers & Factory Girls
 
Moving away from legacy code with BDD
Moving away from legacy code with BDDMoving away from legacy code with BDD
Moving away from legacy code with BDD
 
Gherkin for test automation in agile
Gherkin for test automation in agileGherkin for test automation in agile
Gherkin for test automation in agile
 
Cucumber & BDD
Cucumber & BDDCucumber & BDD
Cucumber & BDD
 
BDD - Writing better scenario
BDD - Writing better scenarioBDD - Writing better scenario
BDD - Writing better scenario
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
 
Programming with python
Programming with pythonProgramming with python
Programming with python
 

Mehr von Kerry Buckley

Ruby nooks & crannies
Ruby nooks & cranniesRuby nooks & crannies
Ruby nooks & cranniesKerry Buckley
 
Tdd for BT E2E test community
Tdd for BT E2E test communityTdd for BT E2E test community
Tdd for BT E2E test communityKerry Buckley
 
What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)Kerry Buckley
 
Functional ruby
Functional rubyFunctional ruby
Functional rubyKerry Buckley
 
MongoMapper lightning talk
MongoMapper lightning talkMongoMapper lightning talk
MongoMapper lightning talkKerry Buckley
 
The secret life of bees
The secret life of beesThe secret life of bees
The secret life of beesKerry Buckley
 
Background processing
Background processingBackground processing
Background processingKerry Buckley
 
Katas, Contests and Coding Dojos
Katas, Contests and Coding DojosKatas, Contests and Coding Dojos
Katas, Contests and Coding DojosKerry Buckley
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST RightKerry Buckley
 
Kanban and Iterationless Working
Kanban and Iterationless WorkingKanban and Iterationless Working
Kanban and Iterationless WorkingKerry Buckley
 
Software Development Trends
Software Development TrendsSoftware Development Trends
Software Development TrendsKerry Buckley
 
Kanban and Iterationless Working
Kanban and Iterationless WorkingKanban and Iterationless Working
Kanban and Iterationless WorkingKerry Buckley
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocksKerry Buckley
 
Behaviour-Driven Development
Behaviour-Driven DevelopmentBehaviour-Driven Development
Behaviour-Driven DevelopmentKerry Buckley
 
REST: putting the web back in to web services
REST: putting the web back in to web servicesREST: putting the web back in to web services
REST: putting the web back in to web servicesKerry Buckley
 

Mehr von Kerry Buckley (20)

Ruby nooks & crannies
Ruby nooks & cranniesRuby nooks & crannies
Ruby nooks & crannies
 
Tdd for BT E2E test community
Tdd for BT E2E test communityTdd for BT E2E test community
Tdd for BT E2E test community
 
What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)
 
Functional ruby
Functional rubyFunctional ruby
Functional ruby
 
MongoMapper lightning talk
MongoMapper lightning talkMongoMapper lightning talk
MongoMapper lightning talk
 
Ruby
RubyRuby
Ruby
 
Cloud
CloudCloud
Cloud
 
The secret life of bees
The secret life of beesThe secret life of bees
The secret life of bees
 
Background processing
Background processingBackground processing
Background processing
 
Katas, Contests and Coding Dojos
Katas, Contests and Coding DojosKatas, Contests and Coding Dojos
Katas, Contests and Coding Dojos
 
Rack
RackRack
Rack
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
Kanban and Iterationless Working
Kanban and Iterationless WorkingKanban and Iterationless Working
Kanban and Iterationless Working
 
Software Development Trends
Software Development TrendsSoftware Development Trends
Software Development Trends
 
TDD
TDDTDD
TDD
 
Kanban and Iterationless Working
Kanban and Iterationless WorkingKanban and Iterationless Working
Kanban and Iterationless Working
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocks
 
Behaviour-Driven Development
Behaviour-Driven DevelopmentBehaviour-Driven Development
Behaviour-Driven Development
 
REST: putting the web back in to web services
REST: putting the web back in to web servicesREST: putting the web back in to web services
REST: putting the web back in to web services
 
Git
GitGit
Git
 

KĂŒrzlich hochgeladen

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
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 AutomationSafe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
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 RobisonAnna Loughnan Colquhoun
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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.pdfUK Journal
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
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)wesley chun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
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 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
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 2024Rafal Los
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 

KĂŒrzlich hochgeladen (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

BDD with cucumber

  • 1. Behaviour-driven development with Cucumber Kerry Buckley BT DevCon6, 4 February 2013 http://www.ïŹ‚ickr.com/photos/yogendra174/4665988849
  • 2.
  • 3. A developer tool for end-to-end testing of ruby web applications
  • 4. A developer tool for end-to-end testing of ruby web applications LIE
  • 6. Feature: DevCon talk In order to fill the DevCon6 schedule As a Cucumber user I want to talk about BDD with Cucumber Scenario: "BDD with Cucumber" talk Given I have managed to prepare a talk And there are people there to hear it When I give the talk Then the audience should learn something
  • 7. Feature: DevCon talk In order to fill the DevCon6 schedule As a Cucumber user I want to talk about BDD with Cucumber Scenario: "BDD with Cucumber" talk Given I have managed to prepare a talk And there are people there to hear it When I give the talk Then the audience should learn something
  • 8. Feature: DevCon talk In order to fill the DevCon6 schedule As a Cucumber user I want to talk about BDD with Cucumber Scenario: "BDD with Cucumber" talk Given I have managed to prepare a talk And there are people there to hear it When I give the talk Then the audience should learn something
  • 9. Feature: DevCon talk In order to fill the DevCon6 schedule As a Cucumber user I want to talk about BDD with Cucumber Scenario: "BDD with Cucumber" talk Given I have managed to prepare a talk And there are people there to hear it When I give the talk Then the audience should learn something
  • 10. Feature: DevCon talk In order to fill the DevCon6 schedule As a Cucumber user I want to talk about BDD with Cucumber Scenario: "BDD with Cucumber" talk Given I have managed to prepare a talk And there are people there to hear it When I give the talk Then the audience should learn something
  • 11. Feature: Withdraw cash from account Scenario: Successful withdrawal Given I have ÂŁ100 in my account When I request a withdrawal of ÂŁ20 Then I should receive ÂŁ20 And my balance should be ÂŁ80
  • 12. $ cucumber withdraw_cash.feature Feature: Withdraw cash from account Scenario: Successful withdrawal # withdraw_cash.feature:3 Given I have ÂŁ100 in my account # withdraw_cash.feature:4 When I request a withdrawal of ÂŁ20 # withdraw_cash.feature:5 Then I should receive ÂŁ20 # withdraw_cash.feature:6 And my balance should be ÂŁ80 # withdraw_cash.feature:7 1 scenario (1 undefined) 4 steps (4 undefined) 0m0.002s You can implement step definitions for undefined steps with these snippets: Given /^I have ÂŁ(d+) in my account$/ do |arg1| pending # express the regexp above with the code you wish you had end ...
  • 13. Scenario: Successful login Given a user "Fred" with password "secret" When I go to the login page And I fill in "User name" with "Fred" And I fill in "Password" with "secret" And I press "Log in" Then I should see "Welcome, Fred"
  • 14. Scenario: Adding a CaaS Linux Service in a production (or test) environment Given a fred production environment exists And I am on the last deployment page When I select "CaaS Linux Service" from "Add a new" And I press "Add service" And I fill in the following: | Role | FTP Server | | Application Installed Software | None | And I select "SC3 (redside)" from "Security Domain" And I select "2" from "Virtual CPUs" And I select "2" from "Virtual Memory" And I select "OEL 5u6 32bit" from "Operating System" And I select "None" from "MaaS(EMB) MQ Client" And I select "None" from "Oracle Client" And I check "Netbackup Client" And I check "XFB Client" And I check "BT Hunter Client" And I check "BTBPTM Client" And I check "Web Tier" And I press "Save" Then I should be on the last deployment page And I should see "Service saved" And I should see ...
  • 15.
  • 16. Scenario: Successful login Given a user "Fred" with password "secret" When I go to the login page And I fill in "User name" with "Fred" And I fill in "Password" with "secret" And I press "Log in" Then I should see "Welcome, Fred"
  • 17. Scenario: User is greeted upon login Given the user "Fred" has an account When he logs in Then he should see "Welcome, Fred"
  • 18. Given /^the user "(.*?)" has an account$/ do |name| @user = User.find_or_create_by_name name, password: "secret" end When /^he logs in$/ do visit "/login" fill_in "User name", with: @user.name fill_in "Password", with: @user.password click_button "Log in" end Then /^he should see "(.*?)"$/ do |text| page.should have_content(text) end
  • 19. Scenario: User is greeted upon login Given the user "Fred" has an account When he logs in Then he should see "Welcome, Fred" Scenario: Secure pages require login When I visit a secure page as a guest Then I should be asked to log in When I log in with a valid account Then I should see the secure page
  • 20.
  • 21. Feature: My awesome system Scenario: Using the system Given the system exists When I use it Then everything should work perfectly
  • 22. A developer tool for end-to-end testing of web applications
  • 23. A developer tool for LIE end-to-end testing of web applications
  • 24. Scenario: create a dir Given a directory named "foo/bar" When I run `file foo/bar` Then the stdout should contain "foo/bar: directory" Scenario: create a file Given a file named "foo/bar/example.txt" with: """ hello world """ When I run `cat foo/bar/example.txt` Then the output should contain exactly "hello world"
  • 25. A tool for end-to- end testing of web applications
  • 26. A tool for end-to- end testing of web LIE applications
  • 27. More feature 
 er 
 features
  • 28. Feature: Posting messages to friends Scenario: Posting a text message Given I am logged in When I post a text message Then my friends should see my message Scenario: Posting a photo Given I am logged in When I post a photo Then my friends should see a thumbnail of my photo And clicking the thumbnail should show the photo
  • 29. Feature: Posting messages to friends Scenario: Posting a text message Given I am logged in When I post a text message Then my friends should see my message Scenario: Posting a photo Given I am logged in When I post a photo Then my friends should see a thumbnail of my photo And clicking the thumbnail should show the photo
  • 30. Feature: Posting messages to friends Background: Given I am logged in Scenario: Posting a text message When I post a text message Then my friends should see my message Scenario: Posting a photo When I post a photo Then my friends should see a thumbnail of my photo And clicking the thumbnail should show the photo
  • 31. Scenario: When I add 1 widget to my order And I add 5 doodahs to my order And I add 2 thingummies to my order Then my basket total should be ÂŁ12.34
  • 32. Scenario: When I add the following to my order: | Quantity | Item | | 1 | widget | | 5 | doodah | | 2 | thingummy | Then my basket total should be ÂŁ12.34
  • 33. Scenario: Simple addition When I calculate 2 + 2 Then the answer should be 4 When I calculate 10 + 5 Then the answer should be 15 Scenario: Simple multiplication When I calculate 2 * 2 Then the answer should be 4 When I calculate 6 * 7 Then the answer should be 42
  • 34. Scenario Outline: Simple arithmetic When I calculate <first> <operation> <second> Then the answer should be <answer> Examples: | first | operation | second | answer | | 2 | + | 2 | 4 | | 10 | + | 5 | 15 | | 2 | * | 2 | 4 | | 6 | * | 7 | 42 |
  • 36. # language: fr FonctionnalitĂ©: Addition Afin de financer mon bonus avec l'argent des pigeons En tant que trader Je souhaite pouvoir additionner 2 chiffres Plan du ScĂ©nario: Addition de produits dĂ©rivĂ©s Soit une calculatrice Etant donnĂ© qu'on tape <a> Et qu'on tape <b> Lorsqu'on tape additionner Alors le rĂ©sultat doit ĂȘtre <somme> Exemples: | a | b | somme | | 2 | 2 | 4 | | 2 | 3 | 5 |
  • 37. # language: es CaracterĂ­stica: adiciĂłn Para evitar hacer errores tontos Como un matemĂĄtico idiota Quiero saber la suma de los nĂșmeros Esquema del escenario: Sumar dos nĂșmeros Dado que he introducido <entrada_1> en la calculadora Y que he introducido <entrada_2> en la calculadora Cuando oprimo el <botĂłn> Entonces el resultado debe ser <resultado> en la pantalla Ejemplos: | entrada_1 | entrada_2 | botĂłn | resultado | | 20 | 30 | add | 50 | | 2 | 5 | add | 7 | | 0 | 40 | add | 40 |
  • 38. # language: de FunktionalitĂ€t: Addition Um dumme Fehler zu vermeiden möchte ich als Matheidiot die Summe zweier Zahlen gesagt bekommen Szenariogrundriss: Zwei Zahlen hinzufĂŒgen Angenommen ich habe <Eingabe_1> in den Taschenrechner eingegeben Und ich habe <Eingabe_2> in den Taschenrechner eingegeben Wenn ich <Knopf> drĂŒcke Dann sollte das Ergebniss auf dem Bildschirm <Ausgabe> sein Beispiele: | Eingabe_1 | Eingabe_2 | Knopf | Ausgabe | | 20 | 30 | add | 50 | | 2 | 5 | add | 7 | | 0 | 40 | add | 40 |
  • 39. # language: en-lol OH HAI: STUFFING MISHUN: CUCUMBR I CAN HAZ IN TEH BEGINNIN 3 CUCUMBRZ WEN I EAT 2 CUCUMBRZ DEN I HAS 2 CUCUMBERZ IN MAH BELLY AN IN TEH END 1 CUCUMBRZ KTHXBAI
  • 40. Getting the most out of Cucumber
  • 42. Given /^the user "(.*?)" has an account$/ do |name| @user = User.find_or_create_by_name name, password: "secret" end Given /^a logged-in user$/ do @user = User.find_or_create_by_name "Fred", password: "secret" visit "/login" fill_in "User name", :with => @user.name fill_in "Password", :with => @user.password click_button "Log in" end When /^he logs in$/ do visit "/login" fill_in "User name", with: @user.name fill_in "Password", with: @user.password click_button "Log in" end Then /^he should see "(.*?)"$/ do |text| page.should have_content(text) end
  • 43. Given /^the user "(.*?)" has an account$/ do |name| @user = User.find_or_create_by_name name, password: "secret" end Given /^a logged-in user$/ do @user = User.find_or_create_by_name "Fred", password: "secret" visit "/login" fill_in "User name", :with => @user.name fill_in "Password", :with => @user.password click_button "Log in" end When /^he logs in$/ do visit "/login" fill_in "User name", with: @user.name fill_in "Password", with: @user.password click_button "Log in" end Then /^he should see "(.*?)"$/ do |text| page.should have_content(text) end
  • 44. module LoginSteps def login(name, password) visit "/login" fill_in "User name", with: name fill_in "Password", with: password click_button "Log in" end end World(LoginSteps) Given /^a logged in user$/ do @user = User.find_or_create_by_name name, password: "secret" login(@user.name, @user.password) end When /^he logs in$/ do login(@user.name, @user.password) end
  • 47. A tool for end-to-end testing of applications
  • 48. A tool for end-to-end testing LIE of applications
  • 49. A tool for testing applications
  • 50. A tool for testingRELY TI applications N EN HER OT EIT UE TR
  • 52. Made-up statistics Identifying scenarios 25% Automated tests 35% Agreeing steps 40%
  • 53. $ cucumber talk.feature Feature: DevCon talk In order to fill the DevCon6 schedule As a Cucumber user I want to talk about BDD with Cucumber Scenario: "BDD with Cucumber" talk # talk.feature:6 Given I have managed to prepare my talk on time # talk_steps.rb:1 And there are people there to hear it # talk_steps.rb:4 When I give the talk # talk_steps.rb:7 Then the audience should learn something # talk_steps.rb:10 1 scenario (1 passed) 4 steps (4 passed) 0m0.002s