Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to make your clients happy with BDD

How to make your clients happy with BDD

Talk about role of narrative in BDD *.features

Konstantin Kudryashov

March 17, 2012
Tweet

More Decks by Konstantin Kudryashov

Other Decks in Programming

Transcript

  1. Agile mentor in KnpLabs since 2011 BDD evangelist Creator of

    Behat, Mink Contributor to Symfony2 framework [email protected] http://github.com/everzet http://card.everzet.com AM who i @everzet senior from-birth web developer in
  2. BUT

  3. Correct WHY? answer should point out: • Added value of

    the feature • Benefitiar of the feature
  4. In order to see top users As a visitor I

    need to be able to sort them by rating
  5. In order to see top users As a visitor I

    need to be able to sort them by rating
  6. In order to get latest news As a visitor I

    need to be able to see last 3 articles on homepage In order to see top users As a visitor I need to be able to sort them by rating
  7. In order to spend my money As a user I

    need to be able to buy rating on site In order to get latest news As a visitor I need to be able to see last 3 articles on homepage In order to see top users As a visitor I need to be able to sort them by rating
  8. X - the benefit or value of the feature Y

    - the person (or role) who will benefit Z - some feature In order to [X] As a [Y] I need [Z] Its strength is that it forces you to identify the value of delivering a story when you first define it. © Dan North ❤ of BDD
  9. In order to spend my money As a user I

    need to be able to buy rating on site In order to get latest news As a visitor I need to be able to see last 3 articles on homepage In order to see top users As a visitor I need to be able to sort them by rating
  10. 2 1 3 In order to spend my money As

    a user I need to be able to buy rating on site In order to get latest news As a visitor I need to be able to see last 3 articles on homepage In order to see top users As a visitor I need to be able to sort them by rating define priorities
  11. Given some initial context (the givens), When an event occurs,

    Then ensure some outcomes. In order to [X] As a [Y] I need [Z] UserStory:
  12. Given some initial context (the givens), When an event occurs,

    Then ensure some outcomes. In order to [X] As a [Y] I need [Z] Given some initial context (the givens), When an event occurs, Then ensure some outcomes. UserStory:
  13. In order to [X] As a [Y] I need [Z]

    Scenario 1: Scenario 2: Given some initial context (the givens), When an event occurs, Then ensure some outcomes. Given some initial context (the givens), When an event occurs, Then ensure some outcomes. UserStory:
  14. A story’s behaviour is simply its acceptance criteria! - if

    the system fulfills all the acceptance criteria, it’s behaving correctly; if it doesn’t, it isn’t.
  15. In order to ... As a ... I need ...

    Scenario: 1st scenario title Scenario: 2nd scenario title Feature: Feature description Given some initial context (the givens) When an event occurs Then ensure some outcomes Given some initial context (the givens) When an event occurs Then ensure some outcomes
  16. 1. feature 2. scenario 3. step ... ... 2. scenario

    3. step ... ... Given some initial context (the givens) When an event occurs Then ensure some outcomes In order to ... As a ... I need ... Given some initial context (the givens) When an event occurs Then ensure some outcomes Scenario: 1st scenario title Scenario: 2nd scenario title Feature: Feature description feature tree
  17. <?php $steps->Given('/^I have a bank account$/', function($world) { $world->account =

    new BankAccount(); } ); <?php $steps->When('/^I deposit (\d+)\$$/', function($world, $dollars) { $world->account->deposit($dollars); } ); Given I have a bank account When I deposit 35$
  18. Then I should have 35$ <?php $steps->Then('/^I should have (\d+)\$$/',

    function($world, $balance) { if ($balance !== $world->account->getBalance()) { throw new \Exception('Wrong balance!'); } } );
  19. <?php $steps->Given('/^I have a bank account$/', function($world) { $world->account =

    new BankAccount(); } ); $steps->When('/^I deposit (\d+)\$$/', function($world, $dollars) { $world->account->deposit($dollars); } ); $steps->Then('/^I should have (\d+)\$$/', function($world, $balance) { assertEquals($balance, $world->account->getBalance()); } );
  20. In order to have extended abilities As a site user

    I need to be able to login Feature: User logins
  21. In order to have extended abilities As a site user

    I need to be able to login Scenario: Existing user can login Feature: User logins
  22. In order to have extended abilities As a site user

    I need to be able to login Scenario: Existing user can login Scenario: Non-existing user can’t login Feature: User logins
  23. Given a site have “everzet” user with “qwerty” password And

    I am on the “/login” When I fill in “username” with “everzet” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Welcome, everzet” In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Given a site have “everzet” user with “qwerty” password And I am on the “/login” When I fill in “username” with “someone” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Login or password is incorrect” Scenario: Non-existing user can’t login Feature: User logins
  24. Given a site have “everzet” user with “qwerty” password And

    I am on the “/login” When I fill in “username” with “everzet” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Welcome, everzet” In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Given a site have “everzet” user with “qwerty” password And I am on the “/login” When I fill in “username” with “someone” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Login or password is incorrect” Scenario: Non-existing user can’t login Feature: User logins
  25. Given I am on the “/login” page When I fill

    in “username” with “everzet” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Welcome, everzet” In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Given I am on the “/login” page When I fill in “username” with “someone” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Login or password is incorrect” Scenario: Non-existing user can’t login Feature: User logins
  26. Given I am on the “/login” page When I fill

    in “username” with “everzet” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Welcome, everzet” In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Given a site have “everzet” user with “qwerty” password Background: Given I am on the “/login” page When I fill in “username” with “someone” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Login or password is incorrect” Scenario: Non-existing user can’t login Feature: User logins
  27. Given I am on the “/login” page When I fill

    in “username” with “everzet” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Welcome, everzet” In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Given a site have users: Background: Given I am on the “/login” page When I fill in “username” with “someone” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Login or password is incorrect” Scenario: Non-existing user can’t login | username | password | | everzet | qwerty | Feature: User logins
  28. Given I am on the “/login” page When I fill

    in “username” with “<username>” And I fill in “password” with “<password>” And I press “login” in login form Then I should see “<message>” In order to have extended abilities As a site user I need to be able to login Scenario Outline: Only existing users can login Given a site have users: Background: | username | password | | everzet | qwerty | Feature: User logins
  29. Given I am on the “/login” page When I fill

    in “username” with “<username>” And I fill in “password” with “<password>” And I press “login” in login form Then I should see “<message>” In order to have extended abilities As a site user I need to be able to login Scenario Outline: Only existing users can login Given a site have users: Background: | username | password | | everzet | qwerty | Examples: Feature: User logins
  30. Given I am on the “/login” page When I fill

    in “username” with “<username>” And I fill in “password” with “<password>” And I press “login” in login form Then I should see “<message>” In order to have extended abilities As a site user I need to be able to login Scenario Outline: Only existing users can login Feature: User logins Given a site have users: Background: | username | password | | everzet | qwerty | Examples: | username | password | message | | everzet | qwerty | Welcome, everzet | | someone | pa$$word | Login or password is incorrect |
  31. Given I am on the “/login” page When I fill

    in “username” with “<username>” And I fill in “password” with “<password>” And I press “login” in login form Then I should see “<message>” In order to have extended abilities As a site user I need to be able to login Scenario Outline: Only existing users can login Feature: User logins Given a site have users: Background: | username | password | | everzet | qwerty | Examples: | username | password | message | | everzet | qwerty | Welcome, everzet | | someone | pa$$word | Login or password is incorrect |
  32. Given I am on the “/login” page When I fill

    in “username” with “<username>” And I fill in “password” with “<password>” And I press “login” in login form Then I should see “<message>” In order to have extended abilities As a site user I need to be able to login Scenario Outline: Only existing users can login Feature: User logins Given a site have users: Background: | username | password | | everzet | qwerty | Examples: | username | password | message | | everzet | qwerty | Welcome, everzet | | someone | pa$$word | Login or password is incorrect | @javascript