The LAZY Developer's Guide to BDD (with Cucumber)

12,156 views

Published on

The slides for my presentation at GeekCamp.sg 2009.

Published in: Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
12,156
On SlideShare
0
From Embeds
0
Number of Embeds
46
Actions
Shares
0
Downloads
165
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

The LAZY Developer's Guide to BDD (with Cucumber)

  1. A LAZY Developer's Guide to BDD (with ) ~ Ng Tze Yang (aka TY)
  2. 2 weeks ago, i changed it to: Everyone gets a little of 's ♥ 2
  3. A LAZY Developer's Guide to BDD (with ) 3
  4. WTF is “LAZY” ?? 4
  5. LAZY= !(TATFT) 5
  6. WTF is “TATFT” ?? 6
  7. 7
  8. Why Not TATFT ?? 8
  9. Why Not TATFT ?? * What is most important for a software ?? 9
  10. Why Not TATFT ?? * What is most important for a software ?? => Business Value 10
  11. Why Not TATFT ?? * What is most important for a software ?? => Business Value * How do we quantify BV ?? 11
  12. Why Not TATFT ?? * What is most important for a software ?? => Business Value * How do we quantify BV ?? => Behaviours 12
  13. BDD ~ Behaviour Driven Development ~ 13
  14. BDD ~ Behaviour Driven Development ~ “BDD facilitates agile development, which is an approach to develop functional software, within reasonable timeline, making everyone happy, without killing anyone, or burning down any bank.” 14
  15. BDD's Core Principles 15
  16. BDD's Core Principles * It's all behaviour “ The business & technology people should be speaking the same words when referring to the same idea, there should not be any translator.” 16
  17. BDD's Core Principles * It's all behaviour Behaviour: the addition of N values should yield the summation of them Example: the addition of 2 + 4 +1 should yield 8 17
  18. BDD's Core Principles * It's all behaviour * Deliver stakeholder value “ Whatever u are doing, it should be delivering business value, or increasing ur ability to deliver value, if the activity doesn't acheive this, stop doing it” 18
  19. BDD's Core Principles * It's all behaviour * Deliver stakeholder value “ Unit testing is important, as it makes refactoring & regression testing easier, which eases maintenace and enhance ur ability to deliver newer features faster” 19
  20. BDD's Core Principles * It's all behaviour * Deliver stakeholder value * Enough is enough “ Do not overengineer, do not overdo upfront planning, analysis and design. Do just enough to get things started in the right direction” 20
  21. BDD's Core Principles * It's all behaviour * Deliver stakeholder value * Enough is enough “ When i wanna go to sentosa from my AMK home, i just goto gothere.sg to do a quick check, and that's good enough, i don't need to get down to switching lanes on CTE, blah blah. ” 21
  22. Cucumber ? Nice to Eat ?! 22
  23. Cucumber ? Nice to Eat ?! * a tool for functional testing 23
  24. Cucumber ? Nice to Eat ?! * a tool for functional testing * by Aslak HellesØy, & many other nice people 24
  25. Cucumber ? Nice to Eat ?! * a tool for functional testing * by Aslak HellesØy, & many other nice people * allows non-technies to express app's functions in plain text 25
  26. Cucumber ? Nice to Eat ?! * a tool for functional testing * by Aslak HellesØy, & many other nice people * allows non-technies to express app's functions in plain text * plain text serves as documentation & executable examples 26
  27. Hmm .. Plain Text ?! 27
  28. A Prettier Plain Text 28
  29. The Title 29
  30. The Narrative 30
  31. Guideline for the Narrative 31
  32. Guideline for the Narrative * identify the stakeholder “ Eg. The system administrator” 32
  33. Guideline for the Narrative * identify the stakeholder * describe the feature he wants “ Eg. Trashing of all invalid purchase orders in the system” 33
  34. Guideline for the Narrative * identify the stakeholder * describe the feature he wants * the reason for wanting it “ Eg. Prevent data corruption” 34
  35. The Acceptance Criterion 35
  36. The Scenario's Title 36
  37. The Scenario's Steps 37
  38. Given | When | Then 38
  39. Given | When | Then * GIVEN ... setting up system to a known state “ Eg 1. Database setup ... Given the following users already exists” “ Eg 2. Visiting a Url ... Given I am on users management page” “ Eg 3. Ensure User's Login ... Given I already login as “HappyMan”” 39
  40. Given | When | Then * GIVEN ... setting up system to a known state * WHEN ... exercising an event “ Eg. Pressing Button ... When I press “Help Me”” 40
  41. Given | When | Then * GIVEN ... setting up system to a known state * WHEN ... exercising an event * THEN ... verifying an outcome “ Eg. Seeing a message ... Then I should see “Login Successful”” 41
  42. Save & Execute It !! * Save at: <PROJECT_ROOT> `~ features/ `- sign_up.feature 42
  43. Save & Execute It !! * Save at: <PROJECT_ROOT> `~ features/ `- sign_up.feature * Run with: #$ cucumber features 43
  44. P1 P2 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. Step Definitions 52
  53. Save & Execute It !! * Save as: <PROJECT_ROOT> `~ features/ `- steps.rb 53
  54. Save & Execute It !! * Save as: <PROJECT_ROOT> `~ features/ `- steps.rb * Run with: #$ cucumber features 54
  55. 55
  56. 56
  57. 57
  58. The Functional Test Model 58
  59. The Generic Model Cucumber * cucumber exec * features/*.feature * features/*.rb 59
  60. The Generic Model Cucumber * cucumber exec Target App * features/*.feature * features/*.rb 60
  61. The Generic Model Cucumber * cucumber exec Target App * features/*.feature * features/*.rb Driver 61
  62. The Generic Webapp Model Cucumber * cucumber exec * features/*.feature * features/*.rb 62
  63. The Generic Webapp Model Cucumber Webapp * cucumber exec * web server * features/*.feature * deployed app * features/*.rb * web browser 63
  64. The Generic Webapp Model Cucumber Webapp * cucumber exec * web server * features/*.feature * deployed files * features/*.rb * web browser Driver * selenium (server+client) 64
  65. FAST FOWARD (Completed: Step Definitions) 65
  66. Before After 66
  67. Before After 67
  68. Before After 68
  69. Before After 69
  70. Before After 70
  71. A New *.rb File <PROJECT_ROOT> `~ features/ `- selenium.rb 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. OK, Let's Run It !! #$ cucumber features 77
  78. 78
  79. 79
  80. Run Selenium Server #$ selenium 80
  81. Run Selenium Server #$ selenium 81
  82. 82
  83. Let's Try Again #$ cucumber features 83
  84. 84
  85. 85
  86. The Missing Part ?? ~ Our Application ~ 86
  87. FAST FOWARD AGAIN (Completed: Application) 87
  88. Let's Run the Webapp #$ ruby app.rb 88
  89. Let's Run the Webapp #$ ruby app.rb 89
  90. 90
  91. Let's Try Once Again #$ cucumber features 91
  92. Let's Try Once Again #$ cucumber features 92
  93. Revision Time 93
  94. Summing Up 1) Capturing user's requirements in a feature file 94
  95. Feature's Title 95
  96. Feature's Narrative 96
  97. Feature's Narrative 97
  98. Feature's Narrative 98
  99. Feature's Narrative 99
  100. Feature's Acceptance Criterion 100
  101. Feature's Acceptance Criterion 101
  102. Feature's Acceptance Criterion 102
  103. Summing Up 1) Capturing user's requirements in a feature file 2) Complete the missing step defintions 103
  104. Step Definitions 104
  105. Summing Up 1) Capturing user's requirements in a feature file 2) Complete the missing step defintions 3) Implement the application 105
  106. Useful Links * Cucumber's Wiki http://wiki.github.com/aslakhellesoy/cucumber * Cucumber's Homepage http://cukes.info/ * BDD @ Wikipedia 106
  107. Recommended Video 107
  108. THE END 108

×