Behavior Driven Development



Behavior Driven Development

0 0


bdd-slides

Short presentation on BDD, based on Dan North's "What's in a Story"

On Github linclark / bdd-slides

Behavior Driven Development

Lin Clark / @linclark

Based on

What's in a Story by Dan Northedited to use Behat style

What's BDD?

A tool to help devs, QA, and stakeholders communicate betterusing simple sentences to describe requirementsin a structured way,which can then be automatically executed as tests.

An Example

What if we were on the Wikipedia team, introducing multilingual support for the first time.

Given I am on "http://es.wikipedia.org/"
When I type "United States" in the search box
  And I press enter
Then I should see the heading "Estados Unidos"
  And I should see the text "(Redirigido desde «United States»)"
  Feature: Account Holder withdraws cash
    I want to withdraw cash from an ATM
    As an Account Holder
    So that I can get money when the bank is closed

  Scenario: Account has sufficient funds
    Given the account balance is $100
      And the card is valid
      And the machine contains enough money
    When the Account Holder requests $20
    Then the ATM should dispense $20
      And the account balance should be $80
      And the card should be returned

  Scenario: Account has insufficient funds
    ...
Feature: Account Holder withdraws cash

Feature Title

describes an action taken by a user

I want to withdraw cash from an ATM
As an Account Holder
So that I can get money when the bank is closed
          

Narrative

Feature description Role Benefit
Scenario: Account has sufficient funds
  ...

Scenario: Account has insufficient funds
  ...
          

Scenario Title

indicate what's different between the scenarios

Given the account balance is $100
  And the card is valid
  And the machine contains enough money
When the Account Holder requests $20
Then the ATM should dispense $20
  And the account balance should be $80
  And the card should be returned
          

Givens, Events, and Outcomes

(aka Givens, Whens, and Thens)

Given the account balance is $100
  And the card is valid
  And the machine contains enough money
          

Givens

should define all of, and no more than, the required context

When the Account Holder requests $20
          

Events

simple, one line if possible

Then the ATM should dispense $20
  And the account balance should be $80
  And the card should be returned
          

Outcomes