• Like
Below And Beneath Tdd  Test Last Development And Other Real World Test Patterns Presentation
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Below And Beneath Tdd Test Last Development And Other Real World Test Patterns Presentation

  • 2,257 views
Published

 

Published in Business , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,257
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
43
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Below And Beneath TDD Test-Last Development and other real world test patterns Noel Rappin @noelrap Pathfinder Development pathf.com railsprescriptions.com
  • 2. http://www.railsrx.com
  • 3. TEST REFACTOR FAIL PASS CODE Rx
  • 4. TEST REFACTOR Why does testing work? FAIL PASS Why does testing fail? CODE Rx
  • 5. TEST REFACTOR What does it mean for testing to “work”? FAIL PASS CODE Rx
  • 6. TEST REFACTOR Improve effectiveness of team and quality of code NOT FAIL PASS A perfect guarantee of code correctness CODE Rx
  • 7. TEST REFACTOR for me, tdd is about confidence & accountability & responsibility & design & reusability & portability & flexibility & testing & FAIL PASS trustworthiness & teamwork & initiative & flow & that's all i can think of at the moment. CODE -- Kent Beck Rx
  • 8. TEST REFACTOR Accurate view of code Small, incremental steps FAIL PASS Scaffold for change Focus for development CODE Rx
  • 9. TEST REFACTOR What does it mean for testing to “fail”? FAIL PASS CODE Rx
  • 10. TEST REFACTOR Decrease efficiency and code quality FAIL PASS CODE Rx
  • 11. TEST REFACTOR “It feels like there's a hidden door that everyone who tests has found and walked through... There are a bunch of us... FAIL PASS that would love to join the party, but don't know where to find the door.” CODE Rx
  • 12. TEST REFACTOR If you are stuck in a window or banging your head against the wall, FAIL PASS this will help you get to the door CODE Rx
  • 13. TEST REFACTOR FAIL PASS CODE Rx
  • 14. TEST REFACTOR Test-Driven Development FAIL PASS CODE Rx
  • 15. TEST REFACTOR AKA: Behavior-Driven Development or FAIL PASS Test-First Programming CODE Rx
  • 16. TEST REFACTOR TDD Code has: small pieces FAIL PASS high cohesion loose coupling minimal side-effects CODE Rx
  • 17. TEST REFACTOR ☺Accurate view of code ☺Small, incremental steps FAIL PASS ☺Scaffold for change ☺Focus for development CODE Rx
  • 18. TEST REFACTOR FAIL PASS CODE Rx
  • 19. TEST Lose the refactoring FAIL PASS CODE Rx
  • 20. TEST Development, that FAIL PASS happens to have tests CODE Rx
  • 21. TEST Symptoms: FAIL PASS Increased duplicaton in code. Long methods CODE Rx
  • 22. TEST Benefits: FAIL PASS May seem faster at first CODE Rx
  • 23. TEST Over time... FAIL PASS CODE Rx
  • 24. TEST ☺Accurate view of code Small, incremental steps FAIL PASS Scaffold for change ☺Focus for development CODE Rx
  • 25. TEST Fix by: FAIL PASS Cleaning up your mess CODE Rx
  • 26. TEST REFACTOR FAIL PASS CODE Rx
  • 27. TEST REFACTOR FAIL PASS TEST FAIL CODE Rx
  • 28. TEST REFACTOR assert_equal(nil, actual) assert_equal(4.314, actual) FAIL PASS TEST actual = 4.314 FAIL CODE Rx
  • 29. TEST REFACTOR Data-Driven Testing or FAIL PASS Using your program as a calculator TEST FAIL CODE Rx
  • 30. TEST REFACTOR Benefits: Failed Test Guaranteed FAIL PASS Value may be hard to calculate TEST FAIL CODE Rx
  • 31. TEST REFACTOR Pitfalls: Can mask ignorance of domain FAIL PASS Can lead to worse TEST problems FAIL CODE Rx
  • 32. TEST REFACTOR Accurate view of code ☺Small, incremental steps FAIL PASS ☺Scaffold for change ☺Focus for development TEST FAIL CODE Rx
  • 33. TEST REFACTOR assert_equal(nil, actual) assert_equal(4.314, actual) FAIL PASS TEST actual = 4.314 FAIL CODE Rx
  • 34. REFACTOR CODE actual = 4.314 assert_equal(4.314, actual) PASS TEST Rx
  • 35. CODE REFACTOR Test-Next Development aka PASS Code-Driven Development TEST Rx
  • 36. CODE REFACTOR Symptoms: No more failing tests Tweaking tests to PASS match code Coverage drop TEST Rx
  • 37. CODE REFACTOR Benefits: Useful when exploring PASS Useful when testing views TEST Rx
  • 38. CODE REFACTOR Pitfalls: Easily slides into worse patterns PASS Hard to avoid coverage gaps TEST Rx
  • 39. CODE REFACTOR Accurate view of code ☺Small, incremental steps PASS Scaffold for change Focus for development TEST Rx
  • 40. CODE REFACTOR Tautology Based Development PASS TEST Rx
  • 41. CODE REFACTOR Definition: Tests that can’t PASS fail TEST Rx
  • 42. CODE REFACTOR Symptoms: Bugs that should have been covered PASS Mock object misuse TEST Rx
  • 43. CODE REFACTOR ☹Accurate view of code ☺Small, incremental steps PASS Scaffold for change ☹Focus for development TEST Rx
  • 44. CODE REFACTOR Mitigation: Try to separate code assertions PASS from application data TEST Rx
  • 45. CODE REFACTOR PASS TEST Rx
  • 46. CODE REFACTOR CODE CODE CODE PASS CODE CODE CODE TEST Rx
  • 47. CODE REFACTOR CODE CODE CODE Test-Last Development PASS CODE CODE CODE TEST Rx
  • 48. CODE REFACTOR CODE Symptoms: CODE Significant coverage drop CODE PASS Uncovered bugs CODE Harder to write tests CODE CODE TEST Rx
  • 49. CODE REFACTOR CODE CODE This is one way in which we talk past each other CODE PASS Unit tests ≠ TDD CODE CODE CODE TEST Rx
  • 50. CODE REFACTOR CODE Pitfall: CODE Tests get more CODE expensive PASS CODE Lower quality tests CODE Programmer boredom CODE TEST Rx
  • 51. CODE REFACTOR CODE CODE Needed when: CODE Hitting corner case PASS CODE Dealing with legacy CODE CODE TEST Rx
  • 52. CODE REFACTOR CODE ☹Accurate view of code CODE ☹Small, incremental steps CODE PASS Scaffold for change CODE ☹Focus for development CODE CODE TEST Rx
  • 53. CODE REFACTOR Escape by: CODE CODE Start the TDD process CODE Don’t look back PASS CODE Catch up to legacy parts as you touch CODE them CODE TEST Rx
  • 54. CODE REFACTOR CODE CODE CODE PASS CODE CODE CODE TEST Rx
  • 55. CODE REFACTOR CODE CODE CODE Run CODE CODE CODE TEST Rx
  • 56. CODE REFACTOR CODE CODE Coverage Driven CODE Development Run CODE CODE CODE TEST Rx
  • 57. CODE REFACTOR CODE CODE Symptom: CODE Run Tests without assertions CODE CODE CODE TEST Rx
  • 58. CODE REFACTOR CODE Why? CODE Minimal approach to CODE Run legacy CODE Hard to reach code CODE CODE TEST Rx
  • 59. CODE REFACTOR CODE ☹Accurate view of code CODE ☹Small, incremental steps CODE Run ☹Scaffold for change CODE ☹Focus for development CODE CODE TEST Rx
  • 60. TEST REFACTOR FAIL PASS CODE Rx
  • 61. TEST REFACTOR TEST TEST TEST TEST FAIL PASS CODE Rx
  • 62. TEST REFACTOR TEST TEST TEST TEST Lots of Test FAIL PASS First Development CODE Rx
  • 63. TEST REFACTOR TEST TEST TEST TEST Symptom: FAIL PASS Lots of test failures at once during initial developmment CODE Rx
  • 64. TEST REFACTOR TEST TEST TEST TEST Benefit: FAIL PASS Allows planning for future code CODE Rx
  • 65. TEST REFACTOR TEST TEST TEST TEST Cost: Loss of focus FAIL PASS Somewhat harder to write code against CODE Rx
  • 66. TEST REFACTOR TEST TEST TEST TEST Middle Ground: FAIL PASS RSpec pending CODE Rx
  • 67. TEST REFACTOR TEST TEST ☺Accurate view of code TEST TEST Small, incremental steps FAIL PASS ☺Scaffold for change Focus for development CODE Rx
  • 68. TEST REFACTOR FAIL PASS CODE Rx
  • 69. SETUP REFACTOR TEST PASS FAIL CODE Rx
  • 70. SETUP REFACTOR TEST Setup Driven Development PASS FAIL CODE Rx
  • 71. SETUP REFACTOR Symptom: TEST Large, brittle setup methods PASS Slow tests FAIL High-level tests CODE Rx
  • 72. SETUP REFACTOR TEST Costs: PASS This is why people hate testing FAIL CODE Rx
  • 73. SETUP REFACTOR Accurate view of code TEST ☹Small, incremental steps PASS ☺Scaffold for change Focus for development FAIL CODE Rx
  • 74. SETUP REFACTOR TEST Escape by: Mock Objects PASS Real unit tests FAIL CODE Rx
  • 75. TEST REFACTOR FAIL PASS CODE Rx
  • 76. TEST REFACTOR Another problem: End to end failures FAIL PASS Lack of focus Expectation failures CODE Rx
  • 77. Cucumber REFACTOR TEST A potential solution PASS FAIL CODE Rx
  • 78. Cucumber REFACTOR TEST Acceptance Test-Driven PASS Development FAIL CODE Rx
  • 79. Cucumber REFACTOR Symptom: TEST PASS You are writing acceptance tests FAIL CODE Rx
  • 80. Cucumber REFACTOR Costs: TEST PASS Additional layer of test code, indirection FAIL CODE Rx
  • 81. Cucumber REFACTOR Benefits: TEST PASS Increased focus, improved feedback FAIL CODE Rx
  • 82. Cucumber REFACTOR ☺Accurate view of code ☺Small, incremental steps TEST PASS ☺Scaffold for change ☺Focus for development FAIL CODE Rx
  • 83. TEST REFACTOR FAIL PASS CODE Rx
  • 84. TEST REFACTOR And So: FAIL PASS CODE Rx
  • 85. TEST REFACTOR Constant feedback and FAIL PASS baby steps CODE Rx
  • 86. TEST REFACTOR Focus on what comes next Failure Driven FAIL PASS Development CODE Rx
  • 87. TEST REFACTOR Good code has small pieces high cohesion FAIL PASS loose coupling minimal side-effects CODE Rx
  • 88. TEST REFACTOR Invisible cost of bugs or FAIL PASS Done vs. “Done Done” CODE Rx
  • 89. TEST REFACTOR Go write some tests! FAIL PASS CODE Rx
  • 90. TEST REFACTOR Rails Test Prescriptions http://www.railsrx.com Pathfinder Development FAIL PASS http://www.pathf.com http://www.pathf.com/blogs @noelrap @railsrx BoF: 9PM CODE Wed Pavillion 9-10 Rx