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. using
    BDD
    How to make
    your clients happy

    View Slide

  2. AM
    who
    i
    @everzet
    senior from-birth web
    developer in

    View Slide

  3. 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

    View Slide

  4. What’s our
    primary job
    ?

    View Slide

  5. to make
    our clients happy
    !

    View Slide

  6. Current state:

    View Slide

  7. more
    awesome
    languages

    View Slide

  8. more
    awesome
    frameworks

    View Slide

  9. more
    awesome
    developers
    http://www.flickr.com/photos/officialgdc/4421337520

    View Slide

  10. clients
    happiness
    = ?

    View Slide

  11. View Slide

  12. clients
    happiness
    =valuable
    product

    View Slide

  13. awesome
    languages ≠valuable
    product

    View Slide

  14. awesome
    languages
    frameworks
    ≠valuable
    product

    View Slide

  15. awesome
    languages
    frameworks
    developers
    ≠valuable
    product

    View Slide

  16. awesome valuable

    View Slide

  17. =
    valuable
    product

    View Slide

  18. popular
    =
    valuable
    product

    View Slide

  19. popular
    useful
    =
    valuable
    product

    View Slide

  20. popular
    useful
    profitable
    =
    valuable
    product

    View Slide

  21. BUT

    View Slide

  22. How
    to bring
    value
    into
    client
    product
    ?

    View Slide

  23. especially,
    when client
    doesn’t know that
    he needs it

    View Slide

  24. By asking

    View Slide

  25. http://www.flickr.com/photos/brendio/71252025

    View Slide

  26. Client wants
    internationalization?

    View Slide

  27. http://www.flickr.com/photos/editor/6698208975

    View Slide

  28. Client wants
    authorization?

    View Slide

  29. http://www.flickr.com/photos/quinnanya/3588989219

    View Slide

  30. Client wants
    this new shiny
    awesome feature?

    View Slide

  31. Well, you got it....

    View Slide

  32. COMMUNICATIONS
    photo by joshfassbind.com

    View Slide

  33. How does it helps?

    View Slide

  34. Correct answers to
    WHY?
    helps you to bring
    higher priority on
    things, that really
    matter

    View Slide

  35. How does the correct
    answer looks like?
    WHY?

    View Slide

  36. View Slide

  37. Correct WHY? answer
    should point out:

    View Slide

  38. Correct WHY? answer
    should point out:
    • Added value of the feature

    View Slide

  39. Correct WHY? answer
    should point out:
    • Added value of the feature
    • Benefitiar of the feature

    View Slide

  40. In order to see top users

    View Slide

  41. In order to see top users
    As a visitor

    View Slide

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

    View Slide

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

    View Slide

  44. 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

    View Slide

  45. 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

    View Slide

  46. 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

    View Slide

  47. 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

    View Slide

  48. 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

    View Slide

  49. In order to [X]
    As a [Y]
    I need [Z]

    View Slide

  50. Hey, it looks like a
    user story!

    View Slide

  51. In order to [X]
    As a [Y]
    I need [Z]
    UserStory:
    it IS

    View Slide

  52. 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:

    View Slide

  53. 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:

    View Slide

  54. 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:

    View Slide

  55. 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.

    View Slide

  56. Acceptance criteria
    could be automated!

    View Slide

  57. View Slide

  58. 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

    View Slide

  59. 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

    View Slide

  60. $steps->Given('/^I have a bank account$/',
    function($world) {
    $world->account = new BankAccount();
    }
    );
    Given I have a bank account

    View Slide

  61. $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);
    }
    );
    Given I have a bank account
    When I deposit 35$

    View Slide

  62. Then I should have 35$

    View Slide

  63. Then I should have 35$
    $steps->Then('/^I should have (\d+)\$$/',
    function($world, $balance) {
    if ($balance !== $world->account->getBalance()) {
    throw new \Exception('Wrong balance!');
    }
    }
    );

    View Slide

  64. $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());
    }
    );

    View Slide

  65. Feature: User logins

    View Slide

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

    View Slide

  67. 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

    View Slide

  68. 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

    View Slide

  69. 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

    View Slide

  70. 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

    View Slide

  71. 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

    View Slide

  72. 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

    View Slide

  73. 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

    View Slide

  74. Given I am on the “/login” page
    When I fill in “username” with “”
    And I fill in “password” with “”
    And I press “login” in login form
    Then I should see “”
    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

    View Slide

  75. Given I am on the “/login” page
    When I fill in “username” with “”
    And I fill in “password” with “”
    And I press “login” in login form
    Then I should see “”
    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

    View Slide

  76. Given I am on the “/login” page
    When I fill in “username” with “”
    And I fill in “password” with “”
    And I press “login” in login form
    Then I should see “”
    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 |

    View Slide

  77. In-browser testing and
    frameworks support

    View Slide

  78. Sahi
    Goutte
    Selenium
    sfBrowser
    Symfony2 Client

    View Slide

  79. Sahi
    Goutte
    Selenium
    sfBrowser
    Symfony2 Client
    through one clean API

    View Slide

  80. M!"#

    View Slide

  81. Given I am on the “/login” page
    When I fill in “username” with “”
    And I fill in “password” with “”
    And I press “login” in login form
    Then I should see “”
    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 |

    View Slide

  82. Given I am on the “/login” page
    When I fill in “username” with “”
    And I fill in “password” with “”
    And I press “login” in login form
    Then I should see “”
    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

    View Slide

  83. Questions?

    View Slide