TDD refresher

776 views
661 views

Published on

TDD talk for new grad

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
776
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
16
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • TDD refresher

    1. 1. Test-drivendevelopment Kerry Buckley 2 November 2012
    2. 2. TDD refresher
    3. 3. Towards TDD 0. manual testing WriteDesign Test Release code
    4. 4. Towards TDD 1. automated testing Write WriteDesign Test Release code tests
    5. 5. Towards TDD 2. test-first development Write WriteDesign Test Release tests code
    6. 6. Towards TDD 3. test-driven developmentDesign Write Run Write test test code Release Run Refactor tests
    7. 7. Towards TDD3. test-driven development Red Green Refactor
    8. 8. Beyond TDD? 4. behaviour-driven development ExecutableCustomer Release examples Red Green TDD Refactor
    9. 9. Types of test
    10. 10. Acceptance tests Test System
    11. 11. Integrated tests Test Test
    12. 12. Unit tests Test TestMock Mock Mock
    13. 13. Anatomy of a test # Given some test accounts➊ Setup account_1 = Account.new(100) account_2 = Account.new(50) # When I transfer money➋ Act transfer(20, from: account_1, to: account_2) # Then the balances should be updated➌ Assert account_1.balance.should eq(80) account_2.balance.should eq(70)
    14. 14. A good test…
    15. 15. A good test…• Expresses the programmer’s intent
    16. 16. A good test…• Expresses the programmer’s intent• Gives confidence that the code works
    17. 17. A good test…• Expresses the programmer’s intent• Gives confidence that the code works• Only tests one thing
    18. 18. A good test…• Expresses the programmer’s intent• Gives confidence that the code works• Only tests one thing• Gives clear failure message
    19. 19. A good test…• Expresses the programmer’s intent• Gives confidence that the code works• Only tests one thing• Gives clear failure message• Is independent of other tests
    20. 20. A good test suite…
    21. 21. A good test suite…• Gives confidence that the system works
    22. 22. A good test suite…• Gives confidence that the system works• Runs quickly
    23. 23. A good test suite…• Gives confidence that the system works• Runs quickly• Is well-maintained
    24. 24. A good test suite…• Gives confidence that the system works• Runs quickly• Is well-maintained• Isolates each area under test
    25. 25. Benefits of TDD
    26. 26. Benefits of TDD• Less manual testing required
    27. 27. Benefits of TDD• Less manual testing required• Faster feedback
    28. 28. Benefits of TDD• Less manual testing required• Faster feedback• Make it safe to change code
    29. 29. Benefits of TDD• Less manual testing required• Faster feedback• Make it safe to change code• Reduced rework and debugging
    30. 30. Benefits of TDD• Less manual testing required• Faster feedback• Make it safe to change code• Reduced rework and debugging• Improved design
    31. 31. How do I start?
    32. 32. How do I start?• Greenfield project? JFDI! Otherwise…
    33. 33. How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first
    34. 34. How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first • Important features
    35. 35. How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first • Important features • Where the most bugs occur
    36. 36. How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first • Important features • Where the most bugs occur• Use TDD for new features
    37. 37. How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first • Important features • Where the most bugs occur• Use TDD for new features• Add tests for bugs when they’re found
    38. 38. Further reading

    ×