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

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

Post on 14-May-2015

4.210 views

Category:

Technology

2 download

Embed Size (px)

DESCRIPTION

The slides for my presentation at GeekCamp.sg 2009.

TRANSCRIPT

  • 1.A LAZY Developer'sGuide 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'sGuide 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 Value10 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 ?? => Behaviours12 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, makingeveryone 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 themExample: the addition of 2 + 4 +1should yield 817 18. BDD's Core Principles* It's all behaviour * Deliver stakeholder value Whatever u are doing, it should be delivering business value, or increasingur 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, whicheases maintenace and enhance ur ability todeliver newer features faster19 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 direction20 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 needto 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 Hellesy, & many other nice people 24 25. Cucumber ? Nice to Eat ?!* a tool for functional testing * by Aslak Hellesy, & 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 Hellesy, & many other nice people * allows non-technies to express app's functions in plain text * plain text serves as documentation & executable examples26 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 purchaseorders 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 Criterion35 36. The Scenario's Title36 37. The Scenario's Steps37 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 Me40 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: `~ features/ `- sign_up.feature 42 43. Save & Execute It !! * Save at: `~ features/ `- sign_up.feature * Run with: #$ cucumber features43 44. P1 P244 45. 45 46. 46 47. 47 48. 48 49. 49 50. 50 51. 51 52. Step Definitions52 53. Save & Execute It !! * Save as: `~ features/`- steps.rb 53 54. Save & Execute It !! * Save as: `~ features/`- steps.rb * Run with: #$ cucumber features54 55. 55 56. 56 57. 57 58. The Functional Test Model 58 59. The Generic Model Cucumber * cucumber exec * features/*.feature * features/*.rb59 60. The Generic Model Cucumber * cucumber execTarget App * features/*.feature * features/*.rb 60 61. The Generic Model Cucumber * cucumber exec Target App * features/*.feature * features/*.rb Driver61 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 After66 67. Before After67 68. Before After68 69. Before After69 70. Before After70 71. A New *.rb File `~ features/ `- selenium.rb71 72. 72 73. 73 74. 74 75. 75 76. 76 77. OK, Let's Run It !! #$ cucumber features77 78. 78 79. 79 80. Run Selenium Server#$ selenium 80 81. Run Selenium Server#$ selenium 81 82. 82 83. Let's Try Again#$ cucumber features83 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.rb88 89. Let's Run the Webapp#$ ruby app.rb89 90. 90 91. Let's Try Once Again#$ cucumber features91 92. Let's Try Once Again#$ cucumber features92 93. Revision Time 93 94. Summing Up 1) Capturing user's requirementsin a feature file94 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 Criterion100 101. Feature's Acceptance Criterion101 102. Feature's Acceptance Criterion102 103. Summing Up 1) Capturing user's requirementsin a feature file 2) Complete the missing stepdefintions103 104. Step Definitions104 105. Summing Up 1) Capturing user's requirementsin a feature file 2) Complete the missing step defintions 3) Implement the application 105 106. Useful Links* Cucumber's Wikihttp://wiki.github.com/aslakhellesoy/cucumber* Cucumber's Homepagehttp://cukes.info/* BDD @ Wikipedia106 107. Recommended Video 107 108. THE END 108