Test Driven Development: A Love Story

1,484 views

Published on

  • Be the first to comment

Test Driven Development: A Love Story

  1. 1. A Love Story@nellshamrellTest Driven DevelopmentTuesday, April 16, 13
  2. 2. CodeTuesday, April 16, 13
  3. 3. Legacy CodeTuesday, April 16, 13
  4. 4. Tuesday, April 16, 13
  5. 5. Tuesday, April 16, 13
  6. 6. Tuesday, April 16, 13
  7. 7. GriefTuesday, April 16, 13
  8. 8. Stages of GriefDenialAngerBargainingDepressionAcceptanceTuesday, April 16, 13
  9. 9. GriefTuesday, April 16, 13
  10. 10. Test Driven Developmentis the keyTDDTuesday, April 16, 13
  11. 11. Tuesday, April 16, 13
  12. 12. DenialTuesday, April 16, 13
  13. 13. I will write testswhen I have timeTuesday, April 16, 13
  14. 14. ChangedClassTuesday, April 16, 13
  15. 15. ChangedClassUnrelatedClassUnrelatedClassTuesday, April 16, 13
  16. 16. ChangedClassUnrelatedClassUnrelatedClassUnrelatedClassTuesday, April 16, 13
  17. 17. ChangedClassUnrelatedClassUnrelatedClassUnrelatedClassUnrelatedClassUnrelatedClassUnrelatedClassUnrelatedClassUnrelatedClassUnrelatedClassUnrelatedClassTuesday, April 16, 13
  18. 18. Deploying without testsis flying blindTuesday, April 16, 13
  19. 19. A magical, better time inthe future never comesTuesday, April 16, 13
  20. 20. The more stress youfeel, the less testingyou will do...- Kent BeckTuesday, April 16, 13
  21. 21. The less testing youdo, the more errorsyou will make- Kent BeckTuesday, April 16, 13
  22. 22. The ideal time towrite tests is nowTuesday, April 16, 13
  23. 23. But...where do I start?Tuesday, April 16, 13
  24. 24. Tuesday, April 16, 13
  25. 25. AngerTuesday, April 16, 13
  26. 26. What were theythinking?!Tuesday, April 16, 13
  27. 27. I cannot changepast actionsTuesday, April 16, 13
  28. 28. I can only changemy own actionsTuesday, April 16, 13
  29. 29. Adding tests to legacycode takes timeTuesday, April 16, 13
  30. 30. Take small steps thatcan be verified- Noel RappinTuesday, April 16, 13
  31. 31. Any new codemust have testsTuesday, April 16, 13
  32. 32. New CodeLegacyCodeCall new testedcode from legacycodeTuesday, April 16, 13
  33. 33. Bugs in code must bereproduced with a testTuesday, April 16, 13
  34. 34. User Steps Test StepsTuesday, April 16, 13
  35. 35. User Steps Test StepsVisit formTuesday, April 16, 13
  36. 36. User Steps Test StepsVisit formLeave field blankTuesday, April 16, 13
  37. 37. User Steps Test StepsVisit formLeave field blankClick “Submit”Tuesday, April 16, 13
  38. 38. User Steps Test StepsVisit formLeave field blankClick “Submit”ApplicationcrashesTuesday, April 16, 13
  39. 39. User Steps Test StepsVisit formLeave field blankClick “Submit”ApplicationcrashesNew objectTuesday, April 16, 13
  40. 40. User Steps Test StepsVisit formLeave field blankClick “Submit”ApplicationcrashesNew objectLeave field blankTuesday, April 16, 13
  41. 41. User Steps Test StepsVisit formLeave field blankClick “Submit”ApplicationcrashesNew objectLeave field blankSave objectTuesday, April 16, 13
  42. 42. User Steps Test StepsVisit formLeave field blankClick “Submit”ApplicationcrashesNew objectLeave field blankSave objectTest returnsexceptionTuesday, April 16, 13
  43. 43. What should my code do?Tuesday, April 16, 13
  44. 44. it “returns a useful error” doendTuesday, April 16, 13
  45. 45. it “returns a useful error” doendnew_object = Object.newTuesday, April 16, 13
  46. 46. it “returns a useful error” doendnew_object = Object.newnew_object.required = nilTuesday, April 16, 13
  47. 47. it “returns a useful error” doendnew_object = Object.newnew_object.required = nilnew_object.save!Tuesday, April 16, 13
  48. 48. it “returns a useful error” doendnew_object = Object.newnew_object.required = nilnew_object.save!new_object.errors.should include(“Required field is blank”)Tuesday, April 16, 13
  49. 49. Use tests to learnlegacy codeTuesday, April 16, 13
  50. 50. Tuesday, April 16, 13
  51. 51. BargainingTuesday, April 16, 13
  52. 52. I write my code,then write my testTuesday, April 16, 13
  53. 53. WriteCodeWriteTestsTuesday, April 16, 13
  54. 54. WriteCodeTuesday, April 16, 13
  55. 55. WriteCodeManuallyTestTuesday, April 16, 13
  56. 56. WriteCodeManuallyTestModifyCodeTuesday, April 16, 13
  57. 57. WriteCodeManuallyTestModifyCodeManuallyTestTuesday, April 16, 13
  58. 58. WriteCodeManuallyTestModifyCodeManuallyTestWriteTestTuesday, April 16, 13
  59. 59. WriteCodeManuallyTestModifyCodeManuallyTestWriteTestModifyCodeTuesday, April 16, 13
  60. 60. WriteCodeManuallyTestModifyCodeManuallyTestWriteTestModifyCodeManuallyTestTuesday, April 16, 13
  61. 61. WriteCodeManuallyTestModifyCodeManuallyTestWriteTestModifyCodeManuallyTestModifyTestTuesday, April 16, 13
  62. 62. Testing last leavesholes in test coverageTuesday, April 16, 13
  63. 63. WriteFailingTestTuesday, April 16, 13
  64. 64. WriteFailingTestMakeTestPassTuesday, April 16, 13
  65. 65. WriteFailingTestMakeTestPassRefactorTuesday, April 16, 13
  66. 66. WriteFailingTestMakeTestPassRefactorRedTuesday, April 16, 13
  67. 67. WriteFailingTestMakeTestPassRefactorRed GreenTuesday, April 16, 13
  68. 68. WriteFailingTestMakeTestPassRefactorRed Green RefactorTuesday, April 16, 13
  69. 69. Never write newfunctionality withouta failing test- Steve Freeman& Nat PryceTuesday, April 16, 13
  70. 70. Testing is about trust- Robert C. MartinTuesday, April 16, 13
  71. 71. Tuesday, April 16, 13
  72. 72. DepressionTuesday, April 16, 13
  73. 73. What’s thepoint?Tuesday, April 16, 13
  74. 74. Change will happenTuesday, April 16, 13
  75. 75. Every line of testedcode is reliable codeTuesday, April 16, 13
  76. 76. Every line of untestedcode is unreliable codeTuesday, April 16, 13
  77. 77. Do the right thingTuesday, April 16, 13
  78. 78. Tuesday, April 16, 13
  79. 79. AcceptanceTuesday, April 16, 13
  80. 80. Tests prevent breakingTuesday, April 16, 13
  81. 81. Tests aredocumentationTuesday, April 16, 13
  82. 82. it “returns the correct rate” dotax_rate(seattle).should == .095endTuesday, April 16, 13
  83. 83. it “returns the correct rate” dotax_rate(seattle).should == .095endit “creates a new object” doget :newassigns(new_object).should_benew_recordendTuesday, April 16, 13
  84. 84. it “returns the correct rate” dotax_rate(seattle).should == .095endit “creates a new object” doget :newassigns(new_object).should_benew_recordendit “saves to the database” doexpect(save_method).tochange{Table.count}.by(1)endTuesday, April 16, 13
  85. 85. Test Driven Codeis better codeTuesday, April 16, 13
  86. 86. ModularLoosely CoupledSmall MethodsTest Driven Code is...Tuesday, April 16, 13
  87. 87. Tests remove fearTuesday, April 16, 13
  88. 88. Tuesday, April 16, 13
  89. 89. LoveTuesday, April 16, 13
  90. 90. Test Drive anexternal API?Tuesday, April 16, 13
  91. 91. My Code APITuesday, April 16, 13
  92. 92. My Code APICalls API methodTuesday, April 16, 13
  93. 93. My Code APICalls API methodSends responseTuesday, April 16, 13
  94. 94. Mocks and StubsTuesday, April 16, 13
  95. 95. A stub is a stand infor an object calledby my codeTuesday, April 16, 13
  96. 96. My Code API StubTuesday, April 16, 13
  97. 97. My CodeCalls API methodAPI StubTuesday, April 16, 13
  98. 98. My CodeCalls API methodSends scriptedresponseAPI StubTuesday, April 16, 13
  99. 99. Mocks are“stubs with attitude”- Russ OlsenTuesday, April 16, 13
  100. 100. My Code API MockTuesday, April 16, 13
  101. 101. My CodeCalls API methodAPI MockTuesday, April 16, 13
  102. 102. My CodeCalls API methodSends scriptedresponseAPI MockTuesday, April 16, 13
  103. 103. My Code API MockTuesday, April 16, 13
  104. 104. My CodeUnexpected method callAPI MockTuesday, April 16, 13
  105. 105. My CodeUnexpected method callAPI MockTest FAILSXTuesday, April 16, 13
  106. 106. The truth is out there(Just need to ask!)Tuesday, April 16, 13
  107. 107. Testing isevolvingTuesday, April 16, 13
  108. 108. Testing isa journeyTuesday, April 16, 13
  109. 109. Test Driven Developmentchanged my codeTuesday, April 16, 13
  110. 110. Test Driven Developmentchanged meTuesday, April 16, 13
  111. 111. Test Driven Developmentis developingbeyond myselfTuesday, April 16, 13
  112. 112. CodeTuesday, April 16, 13
  113. 113. Nell ShamrellSoftware DevelopmentEngineer withBlue Box Inc@nellshamrellTuesday, April 16, 13

×