Below And
  Beneath TDD
Test-Last Development and other
     real world test patterns

                          Noel Rapp...
http://www.railsrx.com
TEST          REFACTOR



FAIL             PASS



       CODE         Rx
TEST                       REFACTOR

       Why does testing work?

FAIL                             PASS
        Why does...
TEST                     REFACTOR


       What does it mean for
        testing to “work”?
FAIL                          ...
TEST                     REFACTOR
       Improve effectiveness
           of team and
          quality of code

         ...
TEST                           REFACTOR
          for me, tdd is about
               confidence &
             accountabi...
TEST                       REFACTOR
       Accurate view of code

       Small, incremental steps

FAIL                   ...
TEST                     REFACTOR


       What does it mean for
         testing to “fail”?
FAIL                         ...
TEST                      REFACTOR


       Decrease efficiency and
            code quality
FAIL                         ...
TEST                      REFACTOR
          “It feels like there's a
       hidden door that everyone
        who tests h...
TEST                      REFACTOR

         If you are stuck in a
       window or banging your
        head against the ...
TEST          REFACTOR



FAIL             PASS



       CODE         Rx
TEST                  REFACTOR


        Test-Driven
       Development
FAIL                     PASS



         CODE    ...
TEST                     REFACTOR
       AKA: Behavior-Driven
          Development

               or
FAIL               ...
TEST                     REFACTOR
         TDD Code has:

           small pieces
FAIL                          PASS
     ...
TEST                       REFACTOR
       ☺Accurate view of code

       ☺Small, incremental steps

FAIL                 ...
TEST          REFACTOR



FAIL             PASS



       CODE         Rx
TEST


       Lose the refactoring
FAIL                          PASS



              CODE               Rx
TEST



       Development, that
FAIL                       PASS
            happens
         to have tests




          ...
TEST

             Symptoms:

FAIL                             PASS
       Increased duplicaton in
                code.

...
TEST

              Benefits:

FAIL                              PASS
       May seem faster at first




                ...
TEST

       Over time...
FAIL                  PASS




       CODE              Rx
TEST
       ☺Accurate view of code

       Small, incremental steps

FAIL                              PASS
         Scaff...
TEST

              Fix by:
FAIL                           PASS
       Cleaning up your mess




           CODE          ...
TEST          REFACTOR



FAIL             PASS



       CODE         Rx
TEST          REFACTOR



FAIL             PASS
                 TEST

              FAIL
       CODE             Rx
TEST                                   REFACTOR


assert_equal(nil, actual)         assert_equal(4.314, actual)
 FAIL     ...
TEST                   REFACTOR
       Data-Driven Testing

               or
FAIL                         PASS
       Usi...
TEST                     REFACTOR

             Benefits:

       Failed Test Guaranteed
FAIL                            P...
TEST                    REFACTOR
            Pitfalls:

       Can mask ignorance
           of domain
FAIL               ...
TEST                       REFACTOR
        Accurate view of code

       ☺Small, incremental steps

FAIL                 ...
TEST                                   REFACTOR


assert_equal(nil, actual)         assert_equal(4.314, actual)
 FAIL     ...
REFACTOR
CODE
 actual = 4.314



                         assert_equal(4.314, actual)
                                    ...
CODE                     REFACTOR

       Test-Next Development

                aka
                               PASS
 ...
CODE                    REFACTOR
            Symptoms:

       No more failing tests

        Tweaking tests to
          ...
CODE                     REFACTOR
             Benefits:

       Useful when exploring
                               PASS...
CODE                       REFACTOR
               Pitfalls:

       Easily slides into worse
               patterns
    ...
CODE                       REFACTOR
        Accurate view of code

       ☺Small, incremental steps

                     ...
CODE                 REFACTOR


       Tautology Based
        Development
                         PASS



           TES...
CODE                    REFACTOR

          Definition:

       Tests that can’t
                           PASS
         ...
CODE                     REFACTOR
            Symptoms:

       Bugs that should have
           been covered
            ...
CODE                       REFACTOR
       ☹Accurate view of code

       ☺Small, incremental steps

                     ...
CODE                   REFACTOR
         Mitigation:

       Try to separate
        code assertions
                     ...
CODE          REFACTOR



                 PASS



       TEST
                    Rx
CODE          REFACTOR
CODE
CODE
CODE
                 PASS
CODE
CODE
CODE
       TEST
                    Rx
CODE                    REFACTOR
CODE
CODE
CODE   Test-Last Development   PASS
CODE
CODE
CODE
               TEST
        ...
CODE                      REFACTOR
CODE
              Symptoms:
CODE
       Significant coverage drop
CODE
               ...
CODE                      REFACTOR
CODE
CODE   This is one way in which
       we talk past each other
CODE
              ...
CODE                    REFACTOR
CODE         Pitfall:
CODE     Tests get more
CODE        expensive
                     ...
CODE                    REFACTOR
CODE
CODE     Needed when:
CODE   Hitting corner case   PASS
CODE   Dealing with legacy
C...
CODE                     REFACTOR
CODE ☹Accurate view of code
CODE ☹Small, incremental steps
CODE
                        ...
CODE                     REFACTOR
            Escape by:
CODE
CODE   Start the TDD process
CODE      Don’t look back      ...
CODE          REFACTOR
CODE
CODE
CODE
                 PASS
CODE
CODE
CODE
       TEST
                    Rx
CODE          REFACTOR
CODE
CODE
CODE
                 Run
CODE
CODE
CODE
       TEST
                       Rx
CODE                 REFACTOR
CODE
CODE
       Coverage Driven
CODE    Development      Run
CODE
CODE
CODE
            TES...
CODE                     REFACTOR
CODE
CODE
              Symptom:
CODE
                                  Run
       Tests...
CODE                  REFACTOR
CODE
              Why?
CODE
       Minimal approach to
CODE
                             R...
CODE                     REFACTOR
CODE ☹Accurate view of code
CODE ☹Small, incremental steps
CODE
                        ...
TEST          REFACTOR



FAIL             PASS



       CODE         Rx
TEST             REFACTOR
TEST TEST
TEST TEST

FAIL                  PASS



            CODE         Rx
TEST                 REFACTOR
TEST TEST
TEST TEST
            Lots of Test
FAIL                        PASS
        First ...
TEST                     REFACTOR
TEST TEST
TEST TEST
             Symptom:

FAIL                              PASS
      ...
TEST                     REFACTOR
TEST TEST
TEST TEST
                Benefit:
FAIL                                PASS
  ...
TEST                      REFACTOR
TEST TEST
TEST TEST      Cost:

            Loss of focus
FAIL                         ...
TEST                       REFACTOR
TEST TEST
TEST TEST
            Middle Ground:
FAIL                            PASS
  ...
TEST                   REFACTOR
TEST TEST
       ☺Accurate view of code
TEST TEST
       Small, incremental steps

FAIL   ...
TEST          REFACTOR



FAIL             PASS



       CODE         Rx
SETUP         REFACTOR

TEST

                 PASS

FAIL

       CODE         Rx
SETUP                   REFACTOR

TEST

       Setup Driven Development PASS


FAIL

               CODE                Rx
SETUP                       REFACTOR
           Symptom:
TEST
       Large, brittle setup
            methods
            ...
SETUP                  REFACTOR

TEST
            Costs:

                            PASS
       This is why people
     ...
SETUP                      REFACTOR
        Accurate view of code
TEST
       ☹Small, incremental steps

                 ...
SETUP                    REFACTOR

TEST
         Escape by:

       Mock Objects         PASS
       Real unit tests
FAIL
...
TEST          REFACTOR



FAIL             PASS



       CODE         Rx
TEST                      REFACTOR
        Another problem:

       End to end failures

FAIL                          PAS...
Cucumber                REFACTOR


TEST
       A potential solution   PASS


FAIL
             CODE                Rx
Cucumber                 REFACTOR


TEST   Acceptance Test-Driven
                                PASS
           Developm...
Cucumber              REFACTOR


           Symptom:
TEST
                          PASS
        You are writing
       ac...
Cucumber                  REFACTOR


               Costs:
TEST
                                  PASS
       Additional l...
Cucumber               REFACTOR


           Benefits:
TEST
                            PASS
         Increased focus,
   ...
Cucumber                   REFACTOR
       ☺Accurate view of code

       ☺Small, incremental steps
TEST
                 ...
TEST          REFACTOR



FAIL             PASS



       CODE         Rx
TEST             REFACTOR


       And So:
FAIL                PASS



       CODE            Rx
TEST                  REFACTOR


       Constant feedback
             and
FAIL                       PASS
          baby ...
TEST                    REFACTOR
       Focus on what
        comes next

       Failure Driven
FAIL                      ...
TEST                     REFACTOR
         Good code has

           small pieces
          high cohesion
FAIL            ...
TEST                     REFACTOR
       Invisible cost of bugs

                or
FAIL                            PASS
 ...
TEST                 REFACTOR


        Go write
       some tests!
FAIL                    PASS



        CODE          ...
TEST                         REFACTOR
         Rails Test Prescriptions

         http://www.railsrx.com

         Pathfin...
Upcoming SlideShare
Loading in...5
×

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

2,408

Published on

Published in: Business, Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,408
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
46
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

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

  1. 1. Below And Beneath TDD Test-Last Development and other real world test patterns Noel Rappin @noelrap Pathfinder Development pathf.com railsprescriptions.com
  2. 2. http://www.railsrx.com
  3. 3. TEST REFACTOR FAIL PASS CODE Rx
  4. 4. TEST REFACTOR Why does testing work? FAIL PASS Why does testing fail? CODE Rx
  5. 5. TEST REFACTOR What does it mean for testing to “work”? FAIL PASS CODE Rx
  6. 6. TEST REFACTOR Improve effectiveness of team and quality of code NOT FAIL PASS A perfect guarantee of code correctness CODE Rx
  7. 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. 8. TEST REFACTOR Accurate view of code Small, incremental steps FAIL PASS Scaffold for change Focus for development CODE Rx
  9. 9. TEST REFACTOR What does it mean for testing to “fail”? FAIL PASS CODE Rx
  10. 10. TEST REFACTOR Decrease efficiency and code quality FAIL PASS CODE Rx
  11. 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. 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. 13. TEST REFACTOR FAIL PASS CODE Rx
  14. 14. TEST REFACTOR Test-Driven Development FAIL PASS CODE Rx
  15. 15. TEST REFACTOR AKA: Behavior-Driven Development or FAIL PASS Test-First Programming CODE Rx
  16. 16. TEST REFACTOR TDD Code has: small pieces FAIL PASS high cohesion loose coupling minimal side-effects CODE Rx
  17. 17. TEST REFACTOR ☺Accurate view of code ☺Small, incremental steps FAIL PASS ☺Scaffold for change ☺Focus for development CODE Rx
  18. 18. TEST REFACTOR FAIL PASS CODE Rx
  19. 19. TEST Lose the refactoring FAIL PASS CODE Rx
  20. 20. TEST Development, that FAIL PASS happens to have tests CODE Rx
  21. 21. TEST Symptoms: FAIL PASS Increased duplicaton in code. Long methods CODE Rx
  22. 22. TEST Benefits: FAIL PASS May seem faster at first CODE Rx
  23. 23. TEST Over time... FAIL PASS CODE Rx
  24. 24. TEST ☺Accurate view of code Small, incremental steps FAIL PASS Scaffold for change ☺Focus for development CODE Rx
  25. 25. TEST Fix by: FAIL PASS Cleaning up your mess CODE Rx
  26. 26. TEST REFACTOR FAIL PASS CODE Rx
  27. 27. TEST REFACTOR FAIL PASS TEST FAIL CODE Rx
  28. 28. TEST REFACTOR assert_equal(nil, actual) assert_equal(4.314, actual) FAIL PASS TEST actual = 4.314 FAIL CODE Rx
  29. 29. TEST REFACTOR Data-Driven Testing or FAIL PASS Using your program as a calculator TEST FAIL CODE Rx
  30. 30. TEST REFACTOR Benefits: Failed Test Guaranteed FAIL PASS Value may be hard to calculate TEST FAIL CODE Rx
  31. 31. TEST REFACTOR Pitfalls: Can mask ignorance of domain FAIL PASS Can lead to worse TEST problems FAIL CODE Rx
  32. 32. TEST REFACTOR Accurate view of code ☺Small, incremental steps FAIL PASS ☺Scaffold for change ☺Focus for development TEST FAIL CODE Rx
  33. 33. TEST REFACTOR assert_equal(nil, actual) assert_equal(4.314, actual) FAIL PASS TEST actual = 4.314 FAIL CODE Rx
  34. 34. REFACTOR CODE actual = 4.314 assert_equal(4.314, actual) PASS TEST Rx
  35. 35. CODE REFACTOR Test-Next Development aka PASS Code-Driven Development TEST Rx
  36. 36. CODE REFACTOR Symptoms: No more failing tests Tweaking tests to PASS match code Coverage drop TEST Rx
  37. 37. CODE REFACTOR Benefits: Useful when exploring PASS Useful when testing views TEST Rx
  38. 38. CODE REFACTOR Pitfalls: Easily slides into worse patterns PASS Hard to avoid coverage gaps TEST Rx
  39. 39. CODE REFACTOR Accurate view of code ☺Small, incremental steps PASS Scaffold for change Focus for development TEST Rx
  40. 40. CODE REFACTOR Tautology Based Development PASS TEST Rx
  41. 41. CODE REFACTOR Definition: Tests that can’t PASS fail TEST Rx
  42. 42. CODE REFACTOR Symptoms: Bugs that should have been covered PASS Mock object misuse TEST Rx
  43. 43. CODE REFACTOR ☹Accurate view of code ☺Small, incremental steps PASS Scaffold for change ☹Focus for development TEST Rx
  44. 44. CODE REFACTOR Mitigation: Try to separate code assertions PASS from application data TEST Rx
  45. 45. CODE REFACTOR PASS TEST Rx
  46. 46. CODE REFACTOR CODE CODE CODE PASS CODE CODE CODE TEST Rx
  47. 47. CODE REFACTOR CODE CODE CODE Test-Last Development PASS CODE CODE CODE TEST Rx
  48. 48. CODE REFACTOR CODE Symptoms: CODE Significant coverage drop CODE PASS Uncovered bugs CODE Harder to write tests CODE CODE TEST Rx
  49. 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. 50. CODE REFACTOR CODE Pitfall: CODE Tests get more CODE expensive PASS CODE Lower quality tests CODE Programmer boredom CODE TEST Rx
  51. 51. CODE REFACTOR CODE CODE Needed when: CODE Hitting corner case PASS CODE Dealing with legacy CODE CODE TEST Rx
  52. 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. 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. 54. CODE REFACTOR CODE CODE CODE PASS CODE CODE CODE TEST Rx
  55. 55. CODE REFACTOR CODE CODE CODE Run CODE CODE CODE TEST Rx
  56. 56. CODE REFACTOR CODE CODE Coverage Driven CODE Development Run CODE CODE CODE TEST Rx
  57. 57. CODE REFACTOR CODE CODE Symptom: CODE Run Tests without assertions CODE CODE CODE TEST Rx
  58. 58. CODE REFACTOR CODE Why? CODE Minimal approach to CODE Run legacy CODE Hard to reach code CODE CODE TEST Rx
  59. 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. 60. TEST REFACTOR FAIL PASS CODE Rx
  61. 61. TEST REFACTOR TEST TEST TEST TEST FAIL PASS CODE Rx
  62. 62. TEST REFACTOR TEST TEST TEST TEST Lots of Test FAIL PASS First Development CODE Rx
  63. 63. TEST REFACTOR TEST TEST TEST TEST Symptom: FAIL PASS Lots of test failures at once during initial developmment CODE Rx
  64. 64. TEST REFACTOR TEST TEST TEST TEST Benefit: FAIL PASS Allows planning for future code CODE Rx
  65. 65. TEST REFACTOR TEST TEST TEST TEST Cost: Loss of focus FAIL PASS Somewhat harder to write code against CODE Rx
  66. 66. TEST REFACTOR TEST TEST TEST TEST Middle Ground: FAIL PASS RSpec pending CODE Rx
  67. 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. 68. TEST REFACTOR FAIL PASS CODE Rx
  69. 69. SETUP REFACTOR TEST PASS FAIL CODE Rx
  70. 70. SETUP REFACTOR TEST Setup Driven Development PASS FAIL CODE Rx
  71. 71. SETUP REFACTOR Symptom: TEST Large, brittle setup methods PASS Slow tests FAIL High-level tests CODE Rx
  72. 72. SETUP REFACTOR TEST Costs: PASS This is why people hate testing FAIL CODE Rx
  73. 73. SETUP REFACTOR Accurate view of code TEST ☹Small, incremental steps PASS ☺Scaffold for change Focus for development FAIL CODE Rx
  74. 74. SETUP REFACTOR TEST Escape by: Mock Objects PASS Real unit tests FAIL CODE Rx
  75. 75. TEST REFACTOR FAIL PASS CODE Rx
  76. 76. TEST REFACTOR Another problem: End to end failures FAIL PASS Lack of focus Expectation failures CODE Rx
  77. 77. Cucumber REFACTOR TEST A potential solution PASS FAIL CODE Rx
  78. 78. Cucumber REFACTOR TEST Acceptance Test-Driven PASS Development FAIL CODE Rx
  79. 79. Cucumber REFACTOR Symptom: TEST PASS You are writing acceptance tests FAIL CODE Rx
  80. 80. Cucumber REFACTOR Costs: TEST PASS Additional layer of test code, indirection FAIL CODE Rx
  81. 81. Cucumber REFACTOR Benefits: TEST PASS Increased focus, improved feedback FAIL CODE Rx
  82. 82. Cucumber REFACTOR ☺Accurate view of code ☺Small, incremental steps TEST PASS ☺Scaffold for change ☺Focus for development FAIL CODE Rx
  83. 83. TEST REFACTOR FAIL PASS CODE Rx
  84. 84. TEST REFACTOR And So: FAIL PASS CODE Rx
  85. 85. TEST REFACTOR Constant feedback and FAIL PASS baby steps CODE Rx
  86. 86. TEST REFACTOR Focus on what comes next Failure Driven FAIL PASS Development CODE Rx
  87. 87. TEST REFACTOR Good code has small pieces high cohesion FAIL PASS loose coupling minimal side-effects CODE Rx
  88. 88. TEST REFACTOR Invisible cost of bugs or FAIL PASS Done vs. “Done Done” CODE Rx
  89. 89. TEST REFACTOR Go write some tests! FAIL PASS CODE Rx
  90. 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
  1. A particular slide catching your eye?

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

×