BDD com Cucumber

Daniel Zimpel Wayhs

danielwayhs@gmail.com

BDD

BDD

BDD

BDD

Gherkin

Gherkin


        Feature: Serve coffee
          Coffee should not be served until paid for
          Coffee should not be served until the button has been pressed
          If there is no coffee left then money should be refunded

        Scenario: Buy last coffee
          Given there are 1 coffees left in the machine
          And I have deposited 1$
          When I press the coffee button
          Then I should be served a coffee
      

Gherkin


        Feature: Serve coffee
          Coffee should not be served until paid for
          Coffee should not be served until the button has been pressed
          If there is no coffee left then money should be refunded

        Scenario: Buy last coffee
          Given there are 1 coffees left in the machine
          And I have deposited 1$
          When I press the coffee button
          Then I should be served a coffee
      

Gherkin


        Feature: Serve coffee
          Coffee should not be served until paid for
          Coffee should not be served until the button has been pressed
          If there is no coffee left then money should be refunded

        Scenario: Buy last coffee
          Given there are 1 coffees left in the machine
          And I have deposited 1$
          When I press the coffee button
          Then I should be served a coffee
      

Gherkin


        Feature: Serve coffee
          Coffee should not be served until paid for
          Coffee should not be served until the button has been pressed
          If there is no coffee left then money should be refunded

        Scenario: Buy last coffee
          Given there are 1 coffees left in the machine
          And I have deposited 1$
          When I press the coffee button
          Then I should be served a coffee
      

Gherkin


        Feature: Serve coffee
          Coffee should not be served until paid for
          Coffee should not be served until the button has been pressed
          If there is no coffee left then money should be refunded

        Scenario: Buy last coffee
          Given there are 1 coffees left in the machine
          And I have deposited 1$
          When I press the coffee button
          Then I should be served a coffee
      

Gherkin


        Feature: Serve coffee
          Coffee should not be served until paid for
          Coffee should not be served until the button has been pressed
          If there is no coffee left then money should be refunded

        Scenario: Buy last coffee
          Given there are 1 coffees left in the machine
          And I have deposited 1$
          When I press the coffee button
          Then I should be served a coffee
      

Gherkin


        Feature: Serve coffee
          Coffee should not be served until paid for
          Coffee should not be served until the button has been pressed
          If there is no coffee left then money should be refunded

        Scenario: Buy last coffee
          Given there are 1 coffees left in the machine
          And I have deposited 1$
          When I press the coffee button
          Then I should be served a coffee
      

Gherkin


          Scenario Outline: eating
          Given there are  cucumbers
          When I eat  cucumbers
          Then I should have  cucumbers

          Examples:
            | start | eat | left |
            |  12   |  5  |  7   |
            |  20   |  5  |  15  |
      

Gherkin


        Funcionalidade: Servir café
          O café não deve ser servido até que seja pago
          O café não deve ser servido até que o botão seja pressionado
          Se não tiver mais café o dinheiro deve ser devolvido

        Cenario: Comprar último café
          Dado que existe 1 café na máquina
          E Eu depositei 1$
          Quando Eu pressiono o botão do café
          Então Eu devo receber café
      

Cucumber

Stack do cucumber

Estrutura de diretórios

Shashikant86/Poltergeist-Demo

Implementando steps


      # features/step_definitions/coffee_steps.rb
      Then "I should be served coffee" do
        @machine.dispensed_drink.should == "coffee"
      end

      Given /there are (\d+) coffees left in the machine/ do |n|
        @machine = Machine.new(n.to_i)
      end
      

Bibliotecas auxiliares

The Cucumber Book

Perguntas?

/