$30 off During Our Annual Pro Sale. View Details »

What is BDD and why should I care?

mattwynne
October 09, 2012

What is BDD and why should I care?

There's a lot of hype around about BDD. Here Matt talks through the basic philosophy behind BDD, how it relates to existing agile practices, and what impact it can have on your team.

mattwynne

October 09, 2012
Tweet

More Decks by mattwynne

Other Decks in Technology

Transcript

  1. What is BDD
    ...and why should I care?
    @mattwynne
    BCS, Edinburgh
    3rd October 2012

    View Slide

  2. Living documentation
    BDD Kickstart.com
    mattwynne.net
    Coaching / blogging
    training
    Collaborating

    View Slide

  3. BDD: Dual Audience
    Stakeholders,
    Customers,
    Users
    Programmers,
    Testers

    View Slide

  4. Problem
    domain
    Solution
    domain

    View Slide

  5. "Behaviour-Driven Development (BDD) builds
    upon Test-Driven Development (TDD) by
    formalising the good habits of the best TDD
    practitioners."
    -- The Cucumber Book, 2011

    View Slide

  6. The best TDD practitioners...
    • Work from the outside-in
    • Use examples to clarify their requirements
    • Develop and use a ubiquitous language

    View Slide

  7. View Slide

  8. UBIQUITOUS
    LANGUAGE

    View Slide

  9. View Slide

  10. DDD + NLP

    View Slide

  11. Language
    matters
    DDD + NLP

    View Slide

  12. OUTSIDE
    IN

    View Slide

  13. Outside-in

    View Slide

  14. Why?

    View Slide

  15. Why?
    Why?
    Why?
    Why?
    Why?

    View Slide

  16. Organisation Goal

    View Slide

  17. Product Features / Epics

    View Slide

  18. User / Stakeholder Stories

    View Slide

  19. VISA subscriptions
    In order to increase subscriptions
    visitors should be able to
    subscribe online with a VISA card
    User / Stakeholder Story

    View Slide

  20. VISA subscriptions
    In order to increase subscriptions
    visitors should be able to
    subscribe online with a VISA card
    User / Stakeholder Story

    View Slide

  21. VISA subscriptions
    In order to increase subscriptions
    visitors should be able to
    subscribe online with a VISA card
    User / Stakeholder Story

    View Slide

  22. VISA subscriptions
    In order to increase subscriptions
    visitors should be able to
    subscribe online with a VISA card
    User / Stakeholder Story

    View Slide

  23. VISA subscriptions
    In order to increase subscriptions
    visitors should be able to
    subscribe online with a VISA card
    Acceptance Criteria

    View Slide

  24. Acceptance Criteria
    •Must support VISA
    •Does not need to support MasterCard, Switch
    •...
    •Customers should be prevented from entering
    invalid credit card details
    • ...
    Credit Card Processing
    Acceptance criteria:

    View Slide

  25. Acceptance Criteria

    View Slide

  26. Are we ready yet?

    View Slide

  27. Really? So tell me...
    "Customers should be prevented from
    entering invalid credit card details"

    View Slide

  28. Really? So tell me...
    "Customers should be prevented from
    entering invalid credit card details"
    • What exactly makes someone's
    credit card details invalid?

    View Slide

  29. Really? So tell me...
    "Customers should be prevented from
    entering invalid credit card details"
    • What exactly makes someone's
    credit card details invalid?
    • Can they use spaces?

    View Slide

  30. Really? So tell me...
    "Customers should be prevented from
    entering invalid credit card details"
    • What exactly makes someone's
    credit card details invalid?
    • Can they use spaces?
    • Should we checksum the digits?

    View Slide

  31. Really? So tell me...
    "Customers should be prevented from
    entering invalid credit card details"
    • What exactly makes someone's
    credit card details invalid?
    • Can they use spaces?
    • Should we checksum the digits?
    • How do we feed back that the details
    are invalid?

    View Slide

  32. Really? So tell me...
    "Customers should be prevented from
    entering invalid credit card details"
    • What exactly makes someone's
    credit card details invalid?
    • Can they use spaces?
    • Should we checksum the digits?
    • How do we feed back that the details
    are invalid?

    View Slide

  33. Really? So tell me...
    "Customers should be prevented from
    entering invalid credit card details"
    • What exactly makes someone's
    credit card details invalid?
    • Can they use spaces?
    • Should we checksum the digits?
    • How do we feed back that the details
    are invalid?
    An
    example would
    be handy right
    about now...

    View Slide

  34. EXAMPLES

    View Slide

  35. Acceptance Criteria

    View Slide

  36. Scenarios

    View Slide

  37. "Customers should be prevented from
    entering invalid credit card details"
    1. Customer enters a credit card number that
    contains only 15 digits
    2. Customer tries to submit the form
    3. form is re-displayed with an error message
    advising Customer that the correct number
    of digits is 16
    For example, imagine this scenario:

    View Slide

  38. "Customers should be prevented from
    entering invalid credit card details"
    1. Customer enters a credit card number that
    contains only 15 digits
    2. Customer tries to submit the form
    3. form is re-displayed with an error message
    advising Customer that the correct number
    of digits is 16
    For example, imagine this scenario:
    Really?
    Always?

    View Slide

  39. "Customers should be prevented from
    entering invalid credit card details"
    1. Customer enters a credit card number that
    contains only 15 digits
    2. Customer tries to submit the form
    3. form is re-displayed with an error message
    advising Customer that the correct number
    of digits is 16
    For example, imagine this scenario:
    What if...?
    Really?
    Always?

    View Slide

  40. Common understanding of
    Done

    View Slide

  41. User Story
    Acceptance
    Criteria
    Scenarios

    View Slide

  42. Scenarios

    View Slide

  43. AUTOMATION

    View Slide

  44. Behaviour = Context + Action + Outcome

    View Slide

  45. Behaviour = Context + Action + Outcome
    Given

    View Slide

  46. Behaviour = Context + Action + Outcome
    Given When

    View Slide

  47. Behaviour = Context + Action + Outcome
    Given When Then

    View Slide

  48. Scenario: Tickle a happy person
    Given I am in a good mood
    When you tickle me
    Then I will giggle

    View Slide

  49. Scenario: Tickle a happy person
    Given I am in a good mood
    When you tickle me
    Then I will giggle

    View Slide

  50. Scenario: Tickle a grumpy person
    Given I am in a bad mood
    When you tickle me
    Then I will giggle

    View Slide

  51. Scenario: Tickle a grumpy person
    Given I am in a bad mood
    When you tickle me
    Then I will giggle
    expected: "tee hee hee",
    got: "bugger off"

    View Slide

  52. Scenario: Tickle a grumpy person
    Given I am in a bad mood
    When you tickle me
    Then I will get cross

    View Slide

  53. Scenario: Attack a happy person
    Given I am in a good mood
    When you kick me in the shins
    Then I will get cross

    View Slide

  54. Scenario: Attack a happy person
    Given I am in a good mood
    When you kick me in the shins
    Then I will get cross

    View Slide

  55. Behaviour = Context + Action + Outcome

    View Slide

  56. Behaviour = Context + Action + Outcome
    Given

    View Slide

  57. Behaviour = Context + Action + Outcome
    Given When

    View Slide

  58. Behaviour = Context + Action + Outcome
    Given When Then

    View Slide

  59. System = ∑(Behaviour)

    View Slide

  60. http://cukes.info/

    View Slide

  61. Javascript

    View Slide

  62. Demo

    View Slide

  63. Gherkin
    (language)

    View Slide

  64. # language: en
    Feature: Division
    In order to avoid silly mistakes
    Cashiers must be able to calculate a fraction
    Scenario: Regular numbers
    Given I have entered 3 into the calculator
    And I have entered 2 into the calculator
    When I press divide
    Then the result should be 1.5 on the screen

    View Slide

  65. # language: ja
    ϑΟʔνϟ: আࢉ
    όΧͳؒҧ͍Λආ͚ΔͨΊʹ
    ༗ཧ਺΋ܭࢉͰ͖Δ͜ͱ
    γφϦΦ: ;ͭ͏ͷ਺஋
    લఏ 3 Λೖྗ
    ͔ͭ 2 Λೖྗ
    ΋͠ divide Λԡͨ͠
    ͳΒ͹ 1.5 Λදࣔ

    View Slide

  66. български
    català
    Cymraeg
    Česky
    dansk
    Deutsch
    English
    Australian
    LOLCAT
    Texan
    español
    eesti keel
    ೔ຊޠ
    한국어
    lietuvių kalba
    latviešu
    Nederlands
    norsk
    polski
    português
    română
    suomi
    français
    hrvatski
    magyar
    Bahasa Indonesia
    italiano
    русский
    Svenska
    Slovensky
    Узбекча
    Tiếng Việt
    简ମதจ
    ൟᱪதจ
    תירבע
    !"#$%&ا

    View Slide

  67. OH HAI: STUFFING
    MISHUN: CUCUMBR
    I CAN HAZ IN TEH BEGINNIN "3" CUCUMBRZ
    WEN I EAT "2" CUCUMBRZ
    DEN I HAZ "2" CUCUMBERZ IN MAH BELLY
    AN IN TEH END "1" CUCUMBRZ KTHXBAI!

    View Slide

  68. Gherkin Fundamentals
    Feature: Feature name
    Description of feature goes here
    Scenario: Scenario name
    Description of scenario goes here
    Given a certain context
    When something happens
    Then an outcome
    And something else
    But not this though
    Scenario: Another scenario name
    Description of another scenario goes here
    ...

    View Slide

  69. FORGET
    THE
    TOOLS

    View Slide

  70. "Let's make toast the American way:
    You burn it, and I'll scrape it"
    - W. E. Demming

    View Slide

  71. View Slide

  72. Plan

    View Slide

  73. Plan Develop

    View Slide

  74. Plan Develop Misery

    View Slide

  75. Plan Develop Testing

    View Slide

  76. Plan Develop Testing

    View Slide

  77. Plan Develop
    Test

    View Slide

  78. So...
    why should I care?

    View Slide

  79. If you're a developer

    View Slide

  80. If you're a developer
    • BDD will help you to focus

    View Slide

  81. If you're a developer
    • BDD will help you to focus
    • BDD will give you confidence to refactor

    View Slide

  82. If you're a developer
    • BDD will help you to focus
    • BDD will give you confidence to refactor
    • BDD will help you to understand the
    business-facing people on your team better

    View Slide

  83. If you're a product owner
    or business analyst

    View Slide

  84. If you're a product owner
    or business analyst
    • BDD will give you a greater insight into the
    complexity of what you're asking for

    View Slide

  85. If you're a product owner
    or business analyst
    • BDD will give you a greater insight into the
    complexity of what you're asking for
    • BDD will give you transparency about what
    the team are doing in each iteration

    View Slide

  86. If you're a product owner
    or business analyst
    • BDD will give you a greater insight into the
    complexity of what you're asking for
    • BDD will give you transparency about what
    the team are doing in each iteration
    • BDD will help your team ship faster

    View Slide

  87. If you're a tester

    View Slide

  88. If you're a tester
    • BDD will mean you can find bugs before
    they've even been written

    View Slide

  89. If you're a tester
    • BDD will mean you can find bugs before
    they've even been written
    • BDD will free you to do interesting,
    creative, exploratory testing

    View Slide

  90. If you're a
    project manager

    View Slide

  91. If you're a
    project manager
    • BDD will help your team achieve a
    steadier, more predictable, and ultimately
    faster pace

    View Slide

  92. Thanks
    [email protected]
    • @mattwynne
    • http://blog.mattwynne.net

    View Slide