Your SlideShare is downloading. ×
0
Test-drivendevelopment     Kerry Buckley   2 November 2012
TDD refresher
Towards TDD         0. manual testing         WriteDesign              Test     Release         code
Towards TDD            1. automated testing         Write     WriteDesign                        Test   Release         co...
Towards TDD          2. test-first development         Write     WriteDesign                        Test   Release         ...
Towards TDD           3. test-driven developmentDesign   Write        Run            Write   test         test           c...
Towards TDD3. test-driven development Red                Green         Refactor
Beyond TDD?      4. behaviour-driven development                   ExecutableCustomer                                Relea...
Types of test
Acceptance tests      Test     System
Integrated tests  Test    Test
Unit tests Test          TestMock        Mock     Mock
Anatomy of a test           # Given some test accounts➊ Setup    account_1 = Account.new(100)           account_2 = Accoun...
A good test…
A good test…• Expresses the programmer’s intent
A good test…• Expresses the programmer’s intent• Gives confidence that the code works
A good test…• Expresses the programmer’s intent• Gives confidence that the code works• Only tests one thing
A good test…• Expresses the programmer’s intent• Gives confidence that the code works• Only tests one thing• Gives clear fa...
A good test…• Expresses the programmer’s intent• Gives confidence that the code works• Only tests one thing• Gives clear fa...
A good test suite…
A good test suite…• Gives confidence that the system works
A good test suite…• Gives confidence that the system works• Runs quickly
A good test suite…• Gives confidence that the system works• Runs quickly• Is well-maintained
A good test suite…• Gives confidence that the system works• Runs quickly• Is well-maintained• Isolates each area under test
Benefits of TDD
Benefits of TDD• Less manual testing required
Benefits of TDD• Less manual testing required• Faster feedback
Benefits of TDD• Less manual testing required• Faster feedback• Make it safe to change code
Benefits of TDD• Less manual testing required• Faster feedback• Make it safe to change code• Reduced rework and debugging
Benefits of TDD• Less manual testing required• Faster feedback• Make it safe to change code• Reduced rework and debugging•...
How do I start?
How do I start?• Greenfield project? JFDI! Otherwise…
How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first
How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first  • Important features
How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first  • Important features  • Where the...
How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first  • Important features  • Where the...
How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first  • Important features  • Where the...
Further reading
Upcoming SlideShare
Loading in...5
×

TDD refresher

472

Published on

TDD talk for new grad

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

No Downloads
Views
Total Views
472
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
15
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
  • Transcript of "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
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×