Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Behavior Driven Development

42,617 views

Published on

Annotated slides from my "Behavior Driven Development" course. Released under Creative Commons share-alike, commercial and derivatives allowed: http://creativecommons.org/licenses/by-sa/3.0/

Published in: Technology, Economy & Finance

Behavior Driven Development

  1. 1. Liz Keogh @lunivore
  2. 2. Behaviour-Driven Development Feature Injection Cynefin and Differentiation Splitting Stories
  3. 3. An Example of an Example Given Fred has bought a microwave And the microwave cost £100 When we refund the microwave Then Fred should be refunded £100.
  4. 4. An Example of an Example Given baby rabbits cost £10 When we sell Snowy the Baby Rabbit Then the customer should be charged £10.
  5. 5. Examples Given a context When an event happens Then an outcome should occur
  6. 6. “Given Scenario” – an antipattern Given Fred puts a microwave in the basket And the microwave cost £100 When Fred buys the microwave Then he should be charged £100 When we refund the microwave Then Fred should be refunded £100.
  7. 7. Cucumber Feature: Addition In order to avoid silly mistakes As a math idiot I want to be told the sum of two numbers Scenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen This is what most people associate with BDD
  8. 8. BDD is about having conversations
  9. 9. BDD should make it easy to create software
  10. 10. A scenario is an idea, not a promise
  11. 11. A scenario is an idea, not a promise
  12. 12. Having conversations
  13. 13. Exercise Think of the best conversations you’ve had. What made them awesome?
  14. 14. Questions Uncertainty IdeasSupport
  15. 15. Boring! Given Fred bought a microwave And has receipt number 1857123 And receipt 1857123 lists it at £100 When we scan the receipt Then the screen should show the list of items When we select the microwave And we refund it And scan Fred’s credit card Then Fred should be refunded £100.
  16. 16. Examples Given a context When an event happens Then an outcome should occur
  17. 17. Make sure you get it right Assume you got it wrong
  18. 18. Is there a context in which this event will create a different outcome?
  19. 19. Examples Given Fred has bought a microwave And the microwave cost £100 And the microwave was on 10% discount When we refund the microwave Then Fred should be refunded £90.
  20. 20. Examples Given Fluffy the baby rabbit is 1 ½ months old When we try to sell Fluffy Then we should be told he’s too young
  21. 21. Is this the only outcome that matters? If we could achieve it with pixies, would it be enough?
  22. 22. Examples Given Fred has bought a microwave And the microwave cost £100 When we refund the microwave Then the microwave should be added to the stock count.
  23. 23. Examples Given each rabbit eats an average of 20g of carrots a day When we sell 10 rabbits And 5 rabbits are born Then our order for carrots should go down by 700g a week
  24. 24. Same scenario? Then Fred should be refunded £100 Then the microwave should be added to the stock count
  25. 25. Same scenario? Then I should be given £20 And £20 should be debited from my account
  26. 26. Then my eyes glaze over… When we select “baby rabbit” from the list of pets And the customer declines all special offers And we want a VAT receipt And we select payment by credit card And the customer is present Then the receipt should say £10 And we should have £10 more takings And the number of rabbits in stock should decrease And …
  27. 27. Then my eyes glaze over more When we click the “Pets” drop-down And we select “baby rabbits” And we click “No” And we check “VAT receipt” And we click “Pay” And we select “Credit Card” And we click “Yes” And …
  28. 28. Exercise Come up with two scenarios with two outcomes from your own work, one of which can be split and one of which can’t. (They don’t have to be about software)
  29. 29. And you can keep going… Given Fred has bought a microwave And the microwave cost £100 And the microwave is faulty When we refund the microwave Then a fault ticket should be printed.
  30. 30. Exercise What other benefits can you think of that might come from talking through different scenarios?
  31. 31. Acceptance criteria vs. Scenarios Given Fred has bought a microwave And the microwave cost £100 And the microwave was on 10% discount When we refund the microwave Then Fred should be refunded £90.
  32. 32. Acceptance criteria vs. Scenarios Given an item was sold with a discount When a customer gets a refund Then he should only be refunded the discounted price.
  33. 33. Acceptance criteria vs. Scenarios Items should be refunded at the price at which they were sold.
  34. 34. Acceptance criteria vs. Scenarios Given Fluffy the baby rabbit is 1 ½ months old When we try to sell Fluffy the baby rabbit Then we should be told that he’s too young
  35. 35. Acceptance criteria vs. Scenarios Given a pet is below recommended selling age When we try to sell that pet Then we should be told that the pet is too young
  36. 36. Acceptance criteria vs. Scenarios We shouldn’t be able to sell pets younger than the recommended selling age
  37. 37. Exercise Can you derive some scenarios from these acceptance criteria? The user should be able to add and remove bold, italics and underlines. When browsing an item, users should be able to see what other users who browsed the item bought. Pets shouldn’t be listed for sale until they’re old enough.
  38. 38. Vision Makes money Saves money Protects money
  39. 39. Goal Needed to go liveIncidental Stake- holder
  40. 40. Capability Users can achieve a business outcome
  41. 41. Feature User interface component which enables a capability
  42. 42. Story A slice through a feature to enable faster feedback
  43. 43. Scenario An example of how the system might behave from a user perspective
  44. 44. Code Ideas turning into realityDeveloper
  45. 45. Vision Goal Capability Feature Story Scenario Code
  46. 46. Vision Goal Capability Feature Story Scenario Code Capability
  47. 47. Vision Goal Capability Feature Story Scenario Code Scenario
  48. 48. Exercise Who are your stakeholders?
  49. 49. Is there a stakeholder for whom this application will not meet their goal?
  50. 50. Are all of the stakeholder’s goals met by this? If we could achieve it with pixies, would it be enough?
  51. 51. Traditional Rework Developers Testers Deliberate Discovery skills
  52. 52. BDD Less Rework Developers Testers Deliberate Discovery skills Testers
  53. 53. Real Options Options have value. Options expire. Never commit early unless you know why.
  54. 54. Developer
  55. 55. The Big Bucket
  56. 56. A Gantt Chart… 1 1 1 3 3 2 2 1 2 3
  57. 57. 1 1 1 3 3 2 2 …on its side
  58. 58. Backlog 1 1 1 3 3 2 2
  59. 59. If a project has no risks, don’t do it.
  60. 60. Prioritizing for deadline $$$$$$$$ $$$$$$$$ $$$$$$$$ $$$$$ $$$$$ $$ $$ $$ Shipped (1 year) Not Shipped Deadline
  61. 61. Minimum Viable Product $$$$$$$$ $$$$$$$$ $$$$$$$$ $$$$$ $$$$$ $$ $$ $$ Shipped (2 months) Not Shipped Not Shipped Shipped (2 months)
  62. 62. Types of Software Differentiators Commodities KatasExpedite
  63. 63. Types of Software Spoilers
  64. 64. Cynefin Simple ComplicatedComplex Chaotic With thanks to David Snowden and Cognitive Edge
  65. 65. Cynefin With thanks to David Snowden and Cognitive Edge Disorder
  66. 66. Cynefin SimpleChaotic With thanks to David Snowden and Cognitive Edge
  67. 67. Cynefin Breaking things down
  68. 68. Cynefin Trying things out
  69. 69. BDD works really well… …hereish.
  70. 70. Exercise Help me stop the spammers!
  71. 71. Fractal beauty Vision Goal Goal Goal Capability Capability Feature Feature Feature Story Story Story Scenario Scenario Code Code Code
  72. 72. Goal Scenario Goal Feature A Real Project Vision Goal Capability Capability Feature Feature Story Story Story Scenario Code Code Code Whoops, forgot Oops, didn’t know about that… Look what I found! Don’t need this… Can’t remember what this was for…
  73. 73. Goal Scenario Goal Feature A Real Project Vision Goal Capability Capability Feature Feature Story Story Story Scenario Code Code Code Whoops, forgot Oops, didn’t know about that… Look what I found! Don’t need this… Can’t remember what this was for… Um Er… Oh! Oh F… Dammit! Hmm! That’s funny! Ooh, look! Interesting! Sh..! Oops!
  74. 74. We’re uncovering better ways of developing software by doing it Vision Goal Goal Goal Capability Capability Feature Feature Feature Story Story Story Scenario Scenario Code Code Code
  75. 75. We’re discovering how to discover stuff by doing it Whoops, forgot Oops, didn’t know about that… Look what I found! Don’t need this… Can’t remember what this was for… Um… Er… Oh! Oh F… Dammit! Hmm! That’s funny! Ooh, look! Interesting! Sh..! Oops!
  76. 76. Different levels of granularity
  77. 77. Risk (Newest Stuff) First Vision Goal Goal Goal Capability Capability Feature Feature Feature Story Story Story Scenario Scenario Code Code Code Feature Goal Capability Scenario Code Story
  78. 78. High-level, risk-first
  79. 79. High-level, risk-first
  80. 80. Exercise What should your board look like now?
  81. 81. Boring! Given Fred has bought a microwave And the microwave cost £100 When we refund the microwave Then Fred should be refunded £100.
  82. 82. Interesting! Given Fred has bought a 120kg fridge-freezer When we refund the fridge-freezer Then um…
  83. 83. Exercise Can you derive a more interesting scenario from these acceptance criteria? The user should be able to add and remove bold, italics and underlines. When browsing an item, users should be able to see what other users who browsed the item bought. Pets shouldn’t be listed for sale until they’re old enough.
  84. 84. Fred Buyer 999 Letsby Avenue London N1 0UC By Spiking Fred Buyer Save New
  85. 85. Stabilizing
  86. 86. Walking Skeleton
  87. 87. Walking Skeleton
  88. 88. By Input
  89. 89. By Output
  90. 90. By Behaviour
  91. 91. With thanks to Michael James
  92. 92. Having conversations
  93. 93. Liz Keogh http://lizkeogh.com @lunivore

×