SlideShare a Scribd company logo
1 of 33
Download to read offline
Joseph W. Yoder




                                                Pragmatic, Not
                                                Dogmatic TDD:
                             Rethinking How We Test

                                               Joseph W. Yoder
                                               The Refactory, Inc.
                                               joe@refactory.com
                                            http://www.refactory.com




                           Bio
                             Joseph Yoder (Founder and Architect, The Refactory;
                               Hillside Board President; Long Term ACM Member)
                                    pattern enthusiast, author of Big Ball of Mud;
                                    programs adaptive software,
                                    runs a development company,
                                    consults top companies on software
                                    needs, agile enthusiast,
                                    amateur photographer,
                                    motorcycle enthusiast,
                                    enjoys dancing samba!!!

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 2




TDD & Testing Best Practices                                                                                             Page - 1
Joseph W. Yoder




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 3




                         Test-Driven Development Cycle




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 4




TDD & Testing Best Practices                                                                                             Page - 2
Joseph W. Yoder




                                                           Add a Test
                                                                design class interface +
                                                               define expected behavior

                                                                       Make Test Pass
                            create actual behavior +
                              most simple solution

                                                                             Refactor
                                                                clean implemented code
                                                                  + adjust class design
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                   Slide - 5




                                      First
                         Classic Test-Driven Development
                  Start
                                                                                                     test fails Write
                                  Re(Write)                                    Check if                         production
                                  a test                                       test fails                       code
                                                                                                                             1 or more
                                                                                                                              tests fail




                                                  test succeeds
                                                                                                   all tests
                                                            Clean up code                           succeed       Check
                                                                                                                 all tests
                                                              (Refactor)                                         succeed



                                        Ship                           Ready to
                                        it!!!                          Release?
                                                                                                                    Short Sprints
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                   Slide - 6




TDD & Testing Best Practices                                                                                                               Page - 3
Joseph W. Yoder




                           TDD Promises
                               1 Tests help you build the right thing
                               2 Tests guide development
                               3 Tests keep you focused
                               4 Tests allow you to change
                                 code safely and quickly
                               5 Tests ensure what you build works
                               6 You will end up with quality code
                               7 You will end up with a good design
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 7




                                Question: Do tests help you
                                build the right things?




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 8




TDD & Testing Best Practices                                                                                             Page - 4
Joseph W. Yoder




                           Common Misperceptions
                                     Tests verify program correctness
                                          3.1415926535…


                                     Tests enable and encourage
                                     well-designed code




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.    Slide - 9




                                           Understanding
                                                   Tests


                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 10




TDD & Testing Best Practices                                                                                              Page - 5
Joseph W. Yoder




                                         Test Target → the thing
                       T                 we are trying to test.

                                         Action → changes environment
                                         or the Test Target.

                                        Assertion → comparison of
                                        expected vs observable outcome
                                        of the action on the Test Target.
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.        Slide - 11




                                                               Test → a sequence
                                                              of at least one action
                                                                  and one assertion

                                                                                                             T   T’



                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.        Slide - 12




TDD & Testing Best Practices                                                                                                   Page - 6
Joseph W. Yoder




                           Good Test Outline
                              1.           Set up
                              2.           Declare the expected results
                              3.           Exercise the test
                              4.           Get the actual results
                              5.           Assert that the actual results
                                           match the expected results


                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 13




                           Testing Questions
                                     What is a good size for a test?
                                          a class?
                                          a set of classes?
                                          a set of interacting functions/methods?


                                     What is important to test?



                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 14




TDD & Testing Best Practices                                                                                              Page - 7
Joseph W. Yoder




                           What to Test
                               Significant scenarios of use, not
                               isolated methods.
                               The difficult parts: Complex interactions,
                               intricate algorithms, tricky business logic
                               Required system qualities
                                    Performance, scalability,
                                     throughput, security...
                               How services respond to normal
                               and exceptional invocations.
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 15




                           What Not to Test
                                 Tests should add value,
                                 not just be an exercise.
                                 Do not test:
                                       setters and getters
                                          (unless they have side effects or are very complex)
                                       every boundary condition; only test
                                        those with significant business value
                                       every exception; only those likely to occur
                                        or that will cause catastrophic problems.
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 16




TDD & Testing Best Practices                                                                                              Page - 8
Joseph W. Yoder




                             Question: Do tests help you
                             build the right things?

                             Answer: Yes. But only if you
                             have the right tests, not
                             superficial tests.

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 17




                   Ten Commandments of Testing
                     1. Test single complete scenarios
                     2. Do not create dependencies between tests
                     3. Only verify a single thing in each assertion
                     4. Respect class encapsulation
                     5. Test limit values and boundaries
                     6. Test expected exceptional scenarios
                     7. Test interactions with other objects
                     8. When you find a bug, write a test to show it
                     9. Do not duplicate application logic in tests
                     10. Keep your test code clean

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 18




TDD & Testing Best Practices                                                                                              Page - 9
Joseph W. Yoder




                                Question: Do tests guide
                                development and keep you
                                focused?




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.            Slide - 19




                           Two Faces of Testing
                       Defining tests                                                                        But you may
                       helps limit                                                                           be missing
                       scope and                                                                             the bigger
                       increases focus                                                                       picture…
                       Tests force you                                                                       Might need to
                       to implement                                                                          consider how
                       functionality                                                                         current
                       instead of                                                                            functionality
                       jumping around                                                                        affects the
                       and tweaking                                                                          rest of the
                       stuff                                                                                 system
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.            Slide - 20




TDD & Testing Best Practices                                                                                                       Page - 10
Joseph W. Yoder




                           Thinking Fast vs. Slow
                                     Fast thinking:
                                     decisions based on
                                     intuition, biases,
                                     ingrained patterns,
                                     and emotions

                                     Slow thinking:
                                     Reasoning, logical
                                     thinking
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 21




                           Take Time For Both
                                     Slow thinking
                                          Pairing and discussion options are
                                           why you want to implement something
                                           a certain way
                                          Sketching, noodling, design spikes
                                     Fast thinking
                                          Fast turns of coding, testing and
                                           quick fixes… (Red/Green)

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 22




TDD & Testing Best Practices                                                                                              Page - 11
Joseph W. Yoder




                        You are not
                        doing TDD!                                                              Common Belief
                      You must create
                                                                                                             You are not
                       your tests first!                                                                     practicing TDD
                                                                                                             correctly
                                                                                                             unless you
                                                                                                             write tests
                                                                                                             first, before
                                                                                                             writing any
                                                                                                             code that is
                                                                                                             tested.
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.               Slide - 23




                           Dogmatic
                                       Synonyms: assertive, bullheaded, categorical,
                                        definite, despotic, determined, dictative,
                                        doctrinaire, domineering, downright, fanatical,
                                        intolerant, narrow-minded, one-sided, overbearing,
                                        peremptory, stubborn, tyrannical, unequivocal

                                       Antonyms: amenable, flexible, manageable

                                   Blindly following the TDD doctrine says you …
                                                           “Must” write your test first!!!


                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.               Slide - 24




TDD & Testing Best Practices                                                                                                          Page - 12
Joseph W. Yoder




                             Is it OK to write tests after
                             you write production code?
                                      Is this cheating?
                                      Does this result in bad code?
                                      Does it result in a bad design?
                                      Does it reinforce “slacker”
                                      tendencies to not write tests?

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 25




                           Pragmatic
                                     Synonyms: businesslike, common, commonsense,
                                      down-to-earth, easy, efficient, hard, hardboiled,
                                      hardheaded, logical, matter-of-fact, mundane, no-
                                      nonsense, practical , rational, realistic, sane,
                                      sensible, sober, unfantastic, unidealistic,
                                      unsentimental

                                     Antonyms: idealistic, unrealistic

                                  Sometimes it is more practical and logical to write
                                    your tests after you write the code!!!

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 26




TDD & Testing Best Practices                                                                                              Page - 13
Joseph W. Yoder




                           Common Practice
                       Tests don’t always get written first.
                  Start
                                                          test fails Write
                          Re(Write)           Check if               production
                          a test              test fails             code




                                                                                                                                    1 or more
                                                                                                                                     tests fail
                                                  test succeeds
                                                                                                   all tests
                                                            Clean up code                           succeed            Check
                                                                                                                      all tests
                                                              (Refactor)                                              succeed



                                        Ship                           Ready to
                                        it!!!                          Release?
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                         Slide - 27




                           A Pragmatic Testing Cycle
                            Tests verify that code works as expected.
                            Tests don’t always guide what code you write.
                         Write some                                                                                   Check if
                                                                            Re(write)
                         production                                                                                   test fails
                                                                            a test
                         code

                                                            Clean up code
                                                              (Refactor)                                     1 or more
                                                                                                             tests fail Check
                                          all tests succeed                                                           all tests
                                                                                                                      succeed
                                         Ship                          Ready to
                                         it!!!                         Release?
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                         Slide - 28




TDD & Testing Best Practices                                                                                                                      Page - 14
Joseph W. Yoder




                           Pragmatic Testing Cycle
                     Alternate between writing
                       test code and production
                       in small steps.
                     Use feedback from tests
                      to verify code (integrate often).
                     Don’t worry whether the chicken or
                      the egg comes first. Sometimes
                      development guides testing.
                     Do what yields the most value!
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 29




                             Question: Do tests guide
                             development and keep
                             you focused?
                             Answer: Yes if you have the
                             right tests. But tests do not
                             tell you if you built it right.
                             Sometimes you need to take
                             a broader look.
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 30




TDD & Testing Best Practices                                                                                              Page - 15
Joseph W. Yoder




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 31




                                Question: Do tests allow you
                                to change code safely and
                                quickly?




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 32




TDD & Testing Best Practices                                                                                              Page - 16
Joseph W. Yoder




                      Test-Driven                                                                   Refactoring
                      Development
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 33




                           Common Wisdom
                                  Work refactoring into your daily routine.

                                  “In almost all cases, I’m opposed to setting aside time
                                  for refactoring. In my view refactoring is not an activity
                                  you set aside time to do. Refactoring is something you
                                  do all the time in little bursts.”—Martin Fowler




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 34




TDD & Testing Best Practices                                                                                              Page - 17
Joseph W. Yoder




                           Testing is Key!!!




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 35




                             Two Refactoring Types*
                                 Floss Refactorings—frequent,
                                 small changes, intermingled
                                 with other programming
                                 (daily health)

                                 Root canal refactorings—
                                 infrequent, protracted
                                 refactoring, during which
                                 programmers do nothing
                                 else (major repair)
                               * Emerson Murphy-Hill and Andrew Black in
                                “Refactoring Tools: Fitness for Purpose”
                               http://web.cecs.pdx.edu/~black/publications/IEEESoftwareRefact.pdf
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 36




TDD & Testing Best Practices                                                                                              Page - 18
Joseph W. Yoder




                             Sometimes it is easier to
                             throw away tests, change the
                             design of your production
                             code, and then write new
                             tests.

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 37




                                    The design of test code
                                    needs to evolve, just like
                                       production code!




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 38




TDD & Testing Best Practices                                                                                              Page - 19
Joseph W. Yoder




                             ….if your tests slow down
                             your ability to make the
                             changes you want to make
                             in production code, rethink
                             whether you want to keep
                             all your tests.

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.               Slide - 39




                                Refactoring                                                                  Test bar should
                              Production Code                                                                continue green


                                                                                         But tests can also
                                                                                           have smells!

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.               Slide - 40




TDD & Testing Best Practices                                                                                                          Page - 20
Joseph W. Yoder




                       Possible Duplicate Code




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.               Slide - 41




                          So, Refactor the Tests!

                                                                                                             Create Test
                                                                                                              Hierarchy


                                                                                                               Pull Up
                                                                                                              Common
                                                                                                                Parts


                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.               Slide - 42




TDD & Testing Best Practices                                                                                                          Page - 21
Joseph W. Yoder




                                                    Additional Test
                                                    Refactorings
                                   Tests have Refactorings
                                    that are specific to test
                                            code …
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 43




                                                                   Test Method
                                                                   Refactorings
                           Replace actions & assertions
                           with simpler equivalent ones:
                                   Add Assertion Explanation
                                   Introduce Assertion Method

                                   Simplify Test Scenario

                                   Separate Action from Assertion

                                   Decompose Assertion
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 44




TDD & Testing Best Practices                                                                                              Page - 22
Joseph W. Yoder




                                                                   Test Class
                                                                   Refactorings
                           Reorganize actions and assertions
                           to reduce duplication:
                                   Add Fixture
                                   Introduce Initialization Method

                                   Inline Initialization Method

                                   Join Incremental Tests

                                   Split Test

                                   Join Similar Tests with Distinct Data
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 45




                             Question: Do tests allow
                             you to change code safely
                             and quickly?
                             Answer: Yes and no. It takes
                             courage to throw away and
                             rewrite your tests.
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 46




TDD & Testing Best Practices                                                                                              Page - 23
Joseph W. Yoder




                      Classic Test-Driven
                      Development Rhythm
                                                                                                        User story-by-story:
                                                                                                                Write the simplest test
                                                                                                                Run the test and fail
                                                                                                                Write the simplest code
                                                                                                                 that will pass the test
                                                                                                                Run the test and pass
                                                                                                        Repeat until a “story”
                                                                                                        is tested and
                                                                                                        implemented
                                                                                                        “Design happens
                                                                                                         between the
                                                                                                         keystrokes”

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                         Slide - 47




                                Question: Do tests help with
                                quality code and good design?




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                         Slide - 48




TDD & Testing Best Practices                                                                                                                    Page - 24
Joseph W. Yoder




                      Another View of
                      Test-Driven Development
                               Requirements                                  Architecture
                                Envisioning                                  Envisioning                     Conceptual Modeling
                              (days/weeks/...)                             (days/weeks/…)
                                                                  Iteration 0: Envisioning



                                                 Iteration Modeling
                                                       (hours)
                                                                                                 a little bit of modeling
                                                      Model Storming                              then a lot of coding
                                                        (minutes)

                                                         Fast
                                                      TDD(hours)
                                            Iteration n: Development
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                  Slide - 49




                           Spike Solutions
                           If some technical difficulty
                              threatens to hold up the
                              system's development,
                           Or you are not sure how to
                            solve a particular problem…
                                   “Put a pair of developers on the
                                     problem for a week or two to
                                     reduce the potential risk”

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                  Slide - 50




TDD & Testing Best Practices                                                                                                             Page - 25
Joseph W. Yoder




                           Pragmatic Testing Questions
                                  What are the most important kinds
                                   of testing you should focus on?
                                  Who should write them?
                                  Who run them?
                                  When are they run?
                                  How are they run?


                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 51




                           Different Kinds of Tests
                           Unit Tests – Tests classes and components
                           Integration Tests – Tests code integration
                           Smoke Tests – Quick tests of core functionality
                           Performance Tests – Test system under load
                           Regression Tests – Tests it is still working
                           Acceptance Tests – Requirements testing
                           System Tests – Test all parts together

                           Common to only focus on Unit Tests in TDD!!!
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 52




TDD & Testing Best Practices                                                                                              Page - 26
Joseph W. Yoder




                           Tests Can Overlap…

                                                                            Smoke
                                                                            Tests                Quality
                                                                                                 Scenario
                                          Integration
                                          Tests                                                              Acceptance
                                                                                                             Tests
                                                                                                             (Functional and
                                                                                                             qualities)
                                                                           Unit
                                                                           Tests



                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                 Slide - 53




                           TDD should be more than…
                                     Developing unit tests along with code

                                     Only checking in tested code with unit
                                     tests + defining some customer
                                     acceptance




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                 Slide - 54




TDD & Testing Best Practices                                                                                                            Page - 27
Joseph W. Yoder




                           Other Techniques for
                           Improving Quality
                              Steve McConnell
                              http://kev.inburke.com/kevin/the-best-ways-to-find-bugs-in-your-code/




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 55




                           Combine and Conquer
                                     The average is 40% for
                                        any one technique…
                                     No one approach is adequate
                                     Combining techniques gives
                                        you much higher quality




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 56




TDD & Testing Best Practices                                                                                              Page - 28
Joseph W. Yoder




                             Question: Do tests help with
                             quality code and good design?

                             Answer: They can but …
                             you need more than tests.


                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                Slide - 57




                        The Agile Dream …


                        Identify some                                         Create some                        Construct based
                        requirements                                       acceptance criteria                     on the tests




                                 Deliver some working                                            Test to verify the
                                       software                                                    requirements
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                Slide - 58




TDD & Testing Best Practices                                                                                                           Page - 29
Joseph W. Yoder




                           Agile Design Values
                                     Core values:
                                           Design Simplicity
                                           Communication
                                           Teamwork
                                           Trust
                                           Satisfying stakeholder needs
                                     Keep learning
                                     Lots of Testing!!!

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                         Slide - 59




                           Pragmatic Test-Driven
                           Development (core process)
                            Tests written & must pass before checking in production code

                         Write some                                                                                   Check if
                                                                            Re(write)
                         production                                                                                   test fails
                                                                            a test
                         code

                                                            Clean up code
                                                              (Refactor)                                     1 or more
                                                                                                             tests fail Check
                                           all tests succeed                                                          all tests
                                                                                                                      succeed
                                         Ship                          Ready to
                                         it!!!                         Release?                                          Short Sprints
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.                         Slide - 60




TDD & Testing Best Practices                                                                                                                    Page - 30
Joseph W. Yoder




                           TDD Challenges
                     1. Lot’s of Unit Tests with classic TDD is
                              not enough to guarantee good design…
                                  Dogmatic TDD can focus on functionality and features rather than design

                     2. Deception that incremental test mode will give you
                              an inductive way to prove it works…probably more
                              deductive and example driven…
                                  All squirrels I see in Illinois are brown, therefore all squirrels are brown….

                     3. TDD or unit tests can hurt the evolution/refactoring
                        phase….“Oh no! Changes might break the tests”
                     4. Not enough Quality Tests are written. Focus often is
                        on function and missing quality.
                     5. Testing Patterns of Collaboration are important,
                        Unit tests on class might not be good enough.
                        Setting up Mocks doesn’t really test collaborations.
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 61




                           Pragmatic Test Driven
                           Development Is…
                                 Practical…
                                       Focus on how testing best fits into and enhances
                                        your current software development practices.
                                 Thinking carefully about how best to validate
                                 that your software meets its requirements.
                                 Developing the optimum set of tests to feel
                                 confident your system keeps working, not
                                 just Unit Testing!
                                 Including both slow and fast
                                 thinking with your tests.
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 62




TDD & Testing Best Practices                                                                                              Page - 31
Joseph W. Yoder




                          Keep It Focused
                          Keep It Fresh
                          Expand your Horizons

                                         …Be Practical




                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.               Slide - 63




                               Where Did All The Time Go?
                                    Muito Obrigado!!!




                  rebecca@wirfs-brock.com                                                                     joe@refactory.com
                    Twitter: @rebeccawb                                                                      Twitter: @metayoda

                                http://refactory.com/training/test-driven-development
                   http://adaptiveobjectmodel.com/2012/01/what-is-pragmatic-tdd/
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.               Slide - 64




TDD & Testing Best Practices                                                                                                          Page - 32
Joseph W. Yoder




                           Minimum Bar for
                           Pragmatic TDD
                                All production code must
                                have tests validating it.
                                Think about tests early in each iteration
                                and how to validate the next release.
                                Core tests include important
                                aspect of your software,
                                what you really care about.
                                Include both slow and fast
                                thinking with your tests.
                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 65




                   Ten Tenets of Testing
                     1. Test single complete scenarios
                     2. Do not create dependencies between tests
                     3. Only verify a single thing in each assertion
                     4. Respect class encapsulation
                     5. Test limit values and boundaries
                     6. Test expected exceptional scenarios
                     7. Test interactions with other objects
                     8. When you find a bug, write a test to show it
                     9. Do not duplicate application logic in tests
                     10. Keep your test code clean

                  Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc.   Slide - 66




TDD & Testing Best Practices                                                                                              Page - 33

More Related Content

What's hot

Postdoc Symposium - Abram Hindle
Postdoc Symposium - Abram HindlePostdoc Symposium - Abram Hindle
Postdoc Symposium - Abram HindleICSM 2011
 
Building Mobile (app) Masterpiece with Distributed Agile
Building Mobile (app) Masterpiece with Distributed AgileBuilding Mobile (app) Masterpiece with Distributed Agile
Building Mobile (app) Masterpiece with Distributed AgileWee Witthawaskul
 
Chapter 1 ASE Slides ppt
Chapter 1 ASE Slides pptChapter 1 ASE Slides ppt
Chapter 1 ASE Slides pptMr SMAK
 
Expert Recommendation with Usage Expertise
Expert Recommendation with Usage ExpertiseExpert Recommendation with Usage Expertise
Expert Recommendation with Usage Expertisedavema
 
Michael Bolton - Two futures of software testing - Sept 2010
Michael Bolton - Two futures of software testing - Sept 2010Michael Bolton - Two futures of software testing - Sept 2010
Michael Bolton - Two futures of software testing - Sept 2010David O'Dowd
 
Acceptance testfurureinmind
Acceptance testfurureinmindAcceptance testfurureinmind
Acceptance testfurureinmindLeanDog
 
Getting started with Agile
Getting started with AgileGetting started with Agile
Getting started with Agilekutuma
 
A tale of bad requirements
A tale of bad requirementsA tale of bad requirements
A tale of bad requirementsFran McKain
 
Effective Strategies for Distributed Testing
Effective Strategies for Distributed TestingEffective Strategies for Distributed Testing
Effective Strategies for Distributed TestingAnand Bagmar
 
TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012
TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012
TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012Tieturi Oy
 
Real developers-dont-need-unit-tests
Real developers-dont-need-unit-testsReal developers-dont-need-unit-tests
Real developers-dont-need-unit-testsSkills Matter
 
Shirly Ronen - User story testing activities
Shirly Ronen - User story testing activitiesShirly Ronen - User story testing activities
Shirly Ronen - User story testing activitiesAgileSparks
 
Webapp acceptance testing a case study
Webapp acceptance testing   a case studyWebapp acceptance testing   a case study
Webapp acceptance testing a case studyekantola
 
Pair Programming, TDD and other impractical things
Pair Programming, TDD and other impractical thingsPair Programming, TDD and other impractical things
Pair Programming, TDD and other impractical thingsMarcello Duarte
 

What's hot (16)

Postdoc Symposium - Abram Hindle
Postdoc Symposium - Abram HindlePostdoc Symposium - Abram Hindle
Postdoc Symposium - Abram Hindle
 
Building Mobile (app) Masterpiece with Distributed Agile
Building Mobile (app) Masterpiece with Distributed AgileBuilding Mobile (app) Masterpiece with Distributed Agile
Building Mobile (app) Masterpiece with Distributed Agile
 
Oxente BDD
Oxente BDDOxente BDD
Oxente BDD
 
Chapter 1 ASE Slides ppt
Chapter 1 ASE Slides pptChapter 1 ASE Slides ppt
Chapter 1 ASE Slides ppt
 
Expert Recommendation with Usage Expertise
Expert Recommendation with Usage ExpertiseExpert Recommendation with Usage Expertise
Expert Recommendation with Usage Expertise
 
Michael Bolton - Two futures of software testing - Sept 2010
Michael Bolton - Two futures of software testing - Sept 2010Michael Bolton - Two futures of software testing - Sept 2010
Michael Bolton - Two futures of software testing - Sept 2010
 
Acceptance testfurureinmind
Acceptance testfurureinmindAcceptance testfurureinmind
Acceptance testfurureinmind
 
Getting started with Agile
Getting started with AgileGetting started with Agile
Getting started with Agile
 
A tale of bad requirements
A tale of bad requirementsA tale of bad requirements
A tale of bad requirements
 
Effective Strategies for Distributed Testing
Effective Strategies for Distributed TestingEffective Strategies for Distributed Testing
Effective Strategies for Distributed Testing
 
TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012
TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012
TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012
 
Real developers-dont-need-unit-tests
Real developers-dont-need-unit-testsReal developers-dont-need-unit-tests
Real developers-dont-need-unit-tests
 
Shirly Ronen - User story testing activities
Shirly Ronen - User story testing activitiesShirly Ronen - User story testing activities
Shirly Ronen - User story testing activities
 
Webapp acceptance testing a case study
Webapp acceptance testing   a case studyWebapp acceptance testing   a case study
Webapp acceptance testing a case study
 
Practical Guide to Unit Testing
Practical Guide to Unit TestingPractical Guide to Unit Testing
Practical Guide to Unit Testing
 
Pair Programming, TDD and other impractical things
Pair Programming, TDD and other impractical thingsPair Programming, TDD and other impractical things
Pair Programming, TDD and other impractical things
 

Viewers also liked

JDD2014: QA to AQ: shifting from quality assurance to agile quality - Joseph ...
JDD2014: QA to AQ: shifting from quality assurance to agile quality - Joseph ...JDD2014: QA to AQ: shifting from quality assurance to agile quality - Joseph ...
JDD2014: QA to AQ: shifting from quality assurance to agile quality - Joseph ...PROIDEA
 
IPSJ/SIGSE201506 パターンWG・AsianPLoP2015報告-公開用
IPSJ/SIGSE201506 パターンWG・AsianPLoP2015報告-公開用IPSJ/SIGSE201506 パターンWG・AsianPLoP2015報告-公開用
IPSJ/SIGSE201506 パターンWG・AsianPLoP2015報告-公開用Hironori Washizaki
 
Evolution of Pattern Languages: Designing Human Actions, Dialogue, & Films (P...
Evolution of Pattern Languages: Designing Human Actions, Dialogue, & Films (P...Evolution of Pattern Languages: Designing Human Actions, Dialogue, & Films (P...
Evolution of Pattern Languages: Designing Human Actions, Dialogue, & Films (P...Takashi Iba
 
大きな泥のカタマリを相手にするためのアジャイルと努力と苦労 by Joe Yoder (XP祭り2014)
大きな泥のカタマリを相手にするためのアジャイルと努力と苦労 by Joe Yoder (XP祭り2014)大きな泥のカタマリを相手にするためのアジャイルと努力と苦労 by Joe Yoder (XP祭り2014)
大きな泥のカタマリを相手にするためのアジャイルと努力と苦労 by Joe Yoder (XP祭り2014)Yasui Tsutomu
 
Testing System Qualities Agile2012 by Rebecca Wirfs-Brock and Joseph Yoder
Testing System Qualities Agile2012 by Rebecca Wirfs-Brock and Joseph YoderTesting System Qualities Agile2012 by Rebecca Wirfs-Brock and Joseph Yoder
Testing System Qualities Agile2012 by Rebecca Wirfs-Brock and Joseph YoderJoseph Yoder
 
AWS Summit Tokyo 2015 megane LT JAWS-UG TRAIN TRAIN 栄光に向かって走って行け
AWS Summit Tokyo 2015 megane LT JAWS-UG TRAIN TRAIN 栄光に向かって走って行けAWS Summit Tokyo 2015 megane LT JAWS-UG TRAIN TRAIN 栄光に向かって走って行け
AWS Summit Tokyo 2015 megane LT JAWS-UG TRAIN TRAIN 栄光に向かって走って行けHajime Ogushi
 
JDD 2016 - Marcin Stozek - Docker. Przewodnik dla poczatkujacych
JDD 2016 - Marcin Stozek - Docker. Przewodnik dla poczatkujacychJDD 2016 - Marcin Stozek - Docker. Przewodnik dla poczatkujacych
JDD 2016 - Marcin Stozek - Docker. Przewodnik dla poczatkujacychPROIDEA
 
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard WorkTaming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard WorkJoseph Yoder
 
AWSでアプリ開発するなら 知っておくべこと
AWSでアプリ開発するなら 知っておくべことAWSでアプリ開発するなら 知っておくべこと
AWSでアプリ開発するなら 知っておくべことKeisuke Nishitani
 
DevOpsとか言う前にAWSエンジニアに知ってほしいアプリケーションのこと
DevOpsとか言う前にAWSエンジニアに知ってほしいアプリケーションのことDevOpsとか言う前にAWSエンジニアに知ってほしいアプリケーションのこと
DevOpsとか言う前にAWSエンジニアに知ってほしいアプリケーションのことTerui Masashi
 

Viewers also liked (10)

JDD2014: QA to AQ: shifting from quality assurance to agile quality - Joseph ...
JDD2014: QA to AQ: shifting from quality assurance to agile quality - Joseph ...JDD2014: QA to AQ: shifting from quality assurance to agile quality - Joseph ...
JDD2014: QA to AQ: shifting from quality assurance to agile quality - Joseph ...
 
IPSJ/SIGSE201506 パターンWG・AsianPLoP2015報告-公開用
IPSJ/SIGSE201506 パターンWG・AsianPLoP2015報告-公開用IPSJ/SIGSE201506 パターンWG・AsianPLoP2015報告-公開用
IPSJ/SIGSE201506 パターンWG・AsianPLoP2015報告-公開用
 
Evolution of Pattern Languages: Designing Human Actions, Dialogue, & Films (P...
Evolution of Pattern Languages: Designing Human Actions, Dialogue, & Films (P...Evolution of Pattern Languages: Designing Human Actions, Dialogue, & Films (P...
Evolution of Pattern Languages: Designing Human Actions, Dialogue, & Films (P...
 
大きな泥のカタマリを相手にするためのアジャイルと努力と苦労 by Joe Yoder (XP祭り2014)
大きな泥のカタマリを相手にするためのアジャイルと努力と苦労 by Joe Yoder (XP祭り2014)大きな泥のカタマリを相手にするためのアジャイルと努力と苦労 by Joe Yoder (XP祭り2014)
大きな泥のカタマリを相手にするためのアジャイルと努力と苦労 by Joe Yoder (XP祭り2014)
 
Testing System Qualities Agile2012 by Rebecca Wirfs-Brock and Joseph Yoder
Testing System Qualities Agile2012 by Rebecca Wirfs-Brock and Joseph YoderTesting System Qualities Agile2012 by Rebecca Wirfs-Brock and Joseph Yoder
Testing System Qualities Agile2012 by Rebecca Wirfs-Brock and Joseph Yoder
 
AWS Summit Tokyo 2015 megane LT JAWS-UG TRAIN TRAIN 栄光に向かって走って行け
AWS Summit Tokyo 2015 megane LT JAWS-UG TRAIN TRAIN 栄光に向かって走って行けAWS Summit Tokyo 2015 megane LT JAWS-UG TRAIN TRAIN 栄光に向かって走って行け
AWS Summit Tokyo 2015 megane LT JAWS-UG TRAIN TRAIN 栄光に向かって走って行け
 
JDD 2016 - Marcin Stozek - Docker. Przewodnik dla poczatkujacych
JDD 2016 - Marcin Stozek - Docker. Przewodnik dla poczatkujacychJDD 2016 - Marcin Stozek - Docker. Przewodnik dla poczatkujacych
JDD 2016 - Marcin Stozek - Docker. Przewodnik dla poczatkujacych
 
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard WorkTaming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
 
AWSでアプリ開発するなら 知っておくべこと
AWSでアプリ開発するなら 知っておくべことAWSでアプリ開発するなら 知っておくべこと
AWSでアプリ開発するなら 知っておくべこと
 
DevOpsとか言う前にAWSエンジニアに知ってほしいアプリケーションのこと
DevOpsとか言う前にAWSエンジニアに知ってほしいアプリケーションのことDevOpsとか言う前にAWSエンジニアに知ってほしいアプリケーションのこと
DevOpsとか言う前にAWSエンジニアに知ってほしいアプリケーションのこと
 

Similar to Pragmatic notdogmatictdd

Pragmatic notdogmatictdd agile2012
Pragmatic notdogmatictdd   agile2012Pragmatic notdogmatictdd   agile2012
Pragmatic notdogmatictdd agile2012drewz lin
 
Distributed agile testing_for_enterprises
Distributed agile testing_for_enterprisesDistributed agile testing_for_enterprises
Distributed agile testing_for_enterprisesThoughtWorks Studios
 
Test Driven Development by Denis Lutz
Test Driven Development by Denis LutzTest Driven Development by Denis Lutz
Test Driven Development by Denis Lutzjazzman1980
 
Agile Software Development in Practice - A Developer Perspective
Agile Software Development in Practice - A Developer PerspectiveAgile Software Development in Practice - A Developer Perspective
Agile Software Development in Practice - A Developer PerspectiveWee Witthawaskul
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012Justin Gordon
 
Software Testing with Agile Requirements Practices
Software Testing with Agile Requirements Practices Software Testing with Agile Requirements Practices
Software Testing with Agile Requirements Practices A B M Moniruzzaman
 
Agile Software Development Process Practice in Thai Culture
Agile Software Development Process Practice in Thai CultureAgile Software Development Process Practice in Thai Culture
Agile Software Development Process Practice in Thai CultureWee Witthawaskul
 
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...Steve Lange
 
Why Test Driven Development?
Why Test Driven Development?Why Test Driven Development?
Why Test Driven Development?Naresh Jain
 
Javascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end DevsJavascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end DevsChris Powers
 
Software Testing Life Cycle
Software Testing Life CycleSoftware Testing Life Cycle
Software Testing Life Cyclegueste730d5
 
Waterfallacies V1 1
Waterfallacies V1 1Waterfallacies V1 1
Waterfallacies V1 1Jorge Boria
 
Continuous Integration, Continuous Quality, Continuous Delivery
Continuous Integration, Continuous Quality, Continuous DeliveryContinuous Integration, Continuous Quality, Continuous Delivery
Continuous Integration, Continuous Quality, Continuous DeliveryJohn Ferguson Smart Limited
 
Approval Tests at Agile 2012
Approval Tests at Agile 2012Approval Tests at Agile 2012
Approval Tests at Agile 2012Lynn Langit
 
Test-Driven Development Reference Card
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference CardSeapine Software
 
Release Management for Large Enterprises
Release Management for Large EnterprisesRelease Management for Large Enterprises
Release Management for Large EnterprisesSalesforce Developers
 

Similar to Pragmatic notdogmatictdd (20)

Pragmatic notdogmatictdd agile2012
Pragmatic notdogmatictdd   agile2012Pragmatic notdogmatictdd   agile2012
Pragmatic notdogmatictdd agile2012
 
Distributed agile testing_for_enterprises
Distributed agile testing_for_enterprisesDistributed agile testing_for_enterprises
Distributed agile testing_for_enterprises
 
Test Driven Development by Denis Lutz
Test Driven Development by Denis LutzTest Driven Development by Denis Lutz
Test Driven Development by Denis Lutz
 
Agile Software Development in Practice - A Developer Perspective
Agile Software Development in Practice - A Developer PerspectiveAgile Software Development in Practice - A Developer Perspective
Agile Software Development in Practice - A Developer Perspective
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012
 
TDD refresher
TDD refresherTDD refresher
TDD refresher
 
Software Testing with Agile Requirements Practices
Software Testing with Agile Requirements Practices Software Testing with Agile Requirements Practices
Software Testing with Agile Requirements Practices
 
Agile Software Development Process Practice in Thai Culture
Agile Software Development Process Practice in Thai CultureAgile Software Development Process Practice in Thai Culture
Agile Software Development Process Practice in Thai Culture
 
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
 
Why Test Driven Development?
Why Test Driven Development?Why Test Driven Development?
Why Test Driven Development?
 
Testing
TestingTesting
Testing
 
Javascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end DevsJavascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end Devs
 
Software Testing Life Cycle
Software Testing Life CycleSoftware Testing Life Cycle
Software Testing Life Cycle
 
Waterfallacies V1 1
Waterfallacies V1 1Waterfallacies V1 1
Waterfallacies V1 1
 
Continuous Integration, Continuous Quality, Continuous Delivery
Continuous Integration, Continuous Quality, Continuous DeliveryContinuous Integration, Continuous Quality, Continuous Delivery
Continuous Integration, Continuous Quality, Continuous Delivery
 
Approval Tests at Agile 2012
Approval Tests at Agile 2012Approval Tests at Agile 2012
Approval Tests at Agile 2012
 
Test-Driven Development Reference Card
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference Card
 
test
testtest
test
 
test
testtest
test
 
Release Management for Large Enterprises
Release Management for Large EnterprisesRelease Management for Large Enterprises
Release Management for Large Enterprises
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

Pragmatic notdogmatictdd

  • 1. Joseph W. Yoder Pragmatic, Not Dogmatic TDD: Rethinking How We Test Joseph W. Yoder The Refactory, Inc. joe@refactory.com http://www.refactory.com Bio Joseph Yoder (Founder and Architect, The Refactory; Hillside Board President; Long Term ACM Member) pattern enthusiast, author of Big Ball of Mud; programs adaptive software, runs a development company, consults top companies on software needs, agile enthusiast, amateur photographer, motorcycle enthusiast, enjoys dancing samba!!! Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 2 TDD & Testing Best Practices Page - 1
  • 2. Joseph W. Yoder Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 3 Test-Driven Development Cycle Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 4 TDD & Testing Best Practices Page - 2
  • 3. Joseph W. Yoder Add a Test design class interface + define expected behavior Make Test Pass create actual behavior + most simple solution Refactor clean implemented code + adjust class design Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 5 First Classic Test-Driven Development Start test fails Write Re(Write) Check if production a test test fails code 1 or more tests fail test succeeds all tests Clean up code succeed Check all tests (Refactor) succeed Ship Ready to it!!! Release? Short Sprints Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 6 TDD & Testing Best Practices Page - 3
  • 4. Joseph W. Yoder TDD Promises 1 Tests help you build the right thing 2 Tests guide development 3 Tests keep you focused 4 Tests allow you to change code safely and quickly 5 Tests ensure what you build works 6 You will end up with quality code 7 You will end up with a good design Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 7 Question: Do tests help you build the right things? Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 8 TDD & Testing Best Practices Page - 4
  • 5. Joseph W. Yoder Common Misperceptions Tests verify program correctness  3.1415926535… Tests enable and encourage well-designed code Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 9 Understanding Tests Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 10 TDD & Testing Best Practices Page - 5
  • 6. Joseph W. Yoder Test Target → the thing T we are trying to test. Action → changes environment or the Test Target. Assertion → comparison of expected vs observable outcome of the action on the Test Target. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 11 Test → a sequence of at least one action and one assertion T T’ Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 12 TDD & Testing Best Practices Page - 6
  • 7. Joseph W. Yoder Good Test Outline 1. Set up 2. Declare the expected results 3. Exercise the test 4. Get the actual results 5. Assert that the actual results match the expected results Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 13 Testing Questions What is a good size for a test?  a class?  a set of classes?  a set of interacting functions/methods? What is important to test? Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 14 TDD & Testing Best Practices Page - 7
  • 8. Joseph W. Yoder What to Test Significant scenarios of use, not isolated methods. The difficult parts: Complex interactions, intricate algorithms, tricky business logic Required system qualities  Performance, scalability, throughput, security... How services respond to normal and exceptional invocations. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 15 What Not to Test Tests should add value, not just be an exercise. Do not test:  setters and getters (unless they have side effects or are very complex)  every boundary condition; only test those with significant business value  every exception; only those likely to occur or that will cause catastrophic problems. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 16 TDD & Testing Best Practices Page - 8
  • 9. Joseph W. Yoder Question: Do tests help you build the right things? Answer: Yes. But only if you have the right tests, not superficial tests. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 17 Ten Commandments of Testing 1. Test single complete scenarios 2. Do not create dependencies between tests 3. Only verify a single thing in each assertion 4. Respect class encapsulation 5. Test limit values and boundaries 6. Test expected exceptional scenarios 7. Test interactions with other objects 8. When you find a bug, write a test to show it 9. Do not duplicate application logic in tests 10. Keep your test code clean Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 18 TDD & Testing Best Practices Page - 9
  • 10. Joseph W. Yoder Question: Do tests guide development and keep you focused? Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 19 Two Faces of Testing Defining tests But you may helps limit be missing scope and the bigger increases focus picture… Tests force you Might need to to implement consider how functionality current instead of functionality jumping around affects the and tweaking rest of the stuff system Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 20 TDD & Testing Best Practices Page - 10
  • 11. Joseph W. Yoder Thinking Fast vs. Slow Fast thinking: decisions based on intuition, biases, ingrained patterns, and emotions Slow thinking: Reasoning, logical thinking Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 21 Take Time For Both Slow thinking  Pairing and discussion options are why you want to implement something a certain way  Sketching, noodling, design spikes Fast thinking  Fast turns of coding, testing and quick fixes… (Red/Green) Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 22 TDD & Testing Best Practices Page - 11
  • 12. Joseph W. Yoder You are not doing TDD! Common Belief You must create You are not your tests first! practicing TDD correctly unless you write tests first, before writing any code that is tested. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 23 Dogmatic  Synonyms: assertive, bullheaded, categorical, definite, despotic, determined, dictative, doctrinaire, domineering, downright, fanatical, intolerant, narrow-minded, one-sided, overbearing, peremptory, stubborn, tyrannical, unequivocal  Antonyms: amenable, flexible, manageable Blindly following the TDD doctrine says you … “Must” write your test first!!! Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 24 TDD & Testing Best Practices Page - 12
  • 13. Joseph W. Yoder Is it OK to write tests after you write production code? Is this cheating? Does this result in bad code? Does it result in a bad design? Does it reinforce “slacker” tendencies to not write tests? Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 25 Pragmatic  Synonyms: businesslike, common, commonsense, down-to-earth, easy, efficient, hard, hardboiled, hardheaded, logical, matter-of-fact, mundane, no- nonsense, practical , rational, realistic, sane, sensible, sober, unfantastic, unidealistic, unsentimental  Antonyms: idealistic, unrealistic Sometimes it is more practical and logical to write your tests after you write the code!!! Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 26 TDD & Testing Best Practices Page - 13
  • 14. Joseph W. Yoder Common Practice Tests don’t always get written first. Start test fails Write Re(Write) Check if production a test test fails code 1 or more tests fail test succeeds all tests Clean up code succeed Check all tests (Refactor) succeed Ship Ready to it!!! Release? Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 27 A Pragmatic Testing Cycle Tests verify that code works as expected. Tests don’t always guide what code you write. Write some Check if Re(write) production test fails a test code Clean up code (Refactor) 1 or more tests fail Check all tests succeed all tests succeed Ship Ready to it!!! Release? Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 28 TDD & Testing Best Practices Page - 14
  • 15. Joseph W. Yoder Pragmatic Testing Cycle Alternate between writing test code and production in small steps. Use feedback from tests to verify code (integrate often). Don’t worry whether the chicken or the egg comes first. Sometimes development guides testing. Do what yields the most value! Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 29 Question: Do tests guide development and keep you focused? Answer: Yes if you have the right tests. But tests do not tell you if you built it right. Sometimes you need to take a broader look. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 30 TDD & Testing Best Practices Page - 15
  • 16. Joseph W. Yoder Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 31 Question: Do tests allow you to change code safely and quickly? Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 32 TDD & Testing Best Practices Page - 16
  • 17. Joseph W. Yoder Test-Driven Refactoring Development Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 33 Common Wisdom Work refactoring into your daily routine. “In almost all cases, I’m opposed to setting aside time for refactoring. In my view refactoring is not an activity you set aside time to do. Refactoring is something you do all the time in little bursts.”—Martin Fowler Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 34 TDD & Testing Best Practices Page - 17
  • 18. Joseph W. Yoder Testing is Key!!! Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 35 Two Refactoring Types* Floss Refactorings—frequent, small changes, intermingled with other programming (daily health) Root canal refactorings— infrequent, protracted refactoring, during which programmers do nothing else (major repair) * Emerson Murphy-Hill and Andrew Black in “Refactoring Tools: Fitness for Purpose” http://web.cecs.pdx.edu/~black/publications/IEEESoftwareRefact.pdf Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 36 TDD & Testing Best Practices Page - 18
  • 19. Joseph W. Yoder Sometimes it is easier to throw away tests, change the design of your production code, and then write new tests. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 37 The design of test code needs to evolve, just like production code! Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 38 TDD & Testing Best Practices Page - 19
  • 20. Joseph W. Yoder ….if your tests slow down your ability to make the changes you want to make in production code, rethink whether you want to keep all your tests. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 39 Refactoring Test bar should Production Code continue green But tests can also have smells! Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 40 TDD & Testing Best Practices Page - 20
  • 21. Joseph W. Yoder Possible Duplicate Code Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 41 So, Refactor the Tests! Create Test Hierarchy Pull Up Common Parts Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 42 TDD & Testing Best Practices Page - 21
  • 22. Joseph W. Yoder Additional Test Refactorings Tests have Refactorings that are specific to test code … Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 43 Test Method Refactorings Replace actions & assertions with simpler equivalent ones: Add Assertion Explanation Introduce Assertion Method Simplify Test Scenario Separate Action from Assertion Decompose Assertion Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 44 TDD & Testing Best Practices Page - 22
  • 23. Joseph W. Yoder Test Class Refactorings Reorganize actions and assertions to reduce duplication: Add Fixture Introduce Initialization Method Inline Initialization Method Join Incremental Tests Split Test Join Similar Tests with Distinct Data Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 45 Question: Do tests allow you to change code safely and quickly? Answer: Yes and no. It takes courage to throw away and rewrite your tests. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 46 TDD & Testing Best Practices Page - 23
  • 24. Joseph W. Yoder Classic Test-Driven Development Rhythm User story-by-story:  Write the simplest test  Run the test and fail  Write the simplest code that will pass the test  Run the test and pass Repeat until a “story” is tested and implemented “Design happens between the keystrokes” Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 47 Question: Do tests help with quality code and good design? Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 48 TDD & Testing Best Practices Page - 24
  • 25. Joseph W. Yoder Another View of Test-Driven Development Requirements Architecture Envisioning Envisioning Conceptual Modeling (days/weeks/...) (days/weeks/…) Iteration 0: Envisioning Iteration Modeling (hours) a little bit of modeling Model Storming then a lot of coding (minutes) Fast TDD(hours) Iteration n: Development Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 49 Spike Solutions If some technical difficulty threatens to hold up the system's development, Or you are not sure how to solve a particular problem… “Put a pair of developers on the problem for a week or two to reduce the potential risk” Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 50 TDD & Testing Best Practices Page - 25
  • 26. Joseph W. Yoder Pragmatic Testing Questions What are the most important kinds of testing you should focus on? Who should write them? Who run them? When are they run? How are they run? Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 51 Different Kinds of Tests Unit Tests – Tests classes and components Integration Tests – Tests code integration Smoke Tests – Quick tests of core functionality Performance Tests – Test system under load Regression Tests – Tests it is still working Acceptance Tests – Requirements testing System Tests – Test all parts together Common to only focus on Unit Tests in TDD!!! Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 52 TDD & Testing Best Practices Page - 26
  • 27. Joseph W. Yoder Tests Can Overlap… Smoke Tests Quality Scenario Integration Tests Acceptance Tests (Functional and qualities) Unit Tests Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 53 TDD should be more than… Developing unit tests along with code Only checking in tested code with unit tests + defining some customer acceptance Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 54 TDD & Testing Best Practices Page - 27
  • 28. Joseph W. Yoder Other Techniques for Improving Quality Steve McConnell http://kev.inburke.com/kevin/the-best-ways-to-find-bugs-in-your-code/ Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 55 Combine and Conquer The average is 40% for any one technique… No one approach is adequate Combining techniques gives you much higher quality Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 56 TDD & Testing Best Practices Page - 28
  • 29. Joseph W. Yoder Question: Do tests help with quality code and good design? Answer: They can but … you need more than tests. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 57 The Agile Dream … Identify some Create some Construct based requirements acceptance criteria on the tests Deliver some working Test to verify the software requirements Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 58 TDD & Testing Best Practices Page - 29
  • 30. Joseph W. Yoder Agile Design Values Core values:  Design Simplicity  Communication  Teamwork  Trust  Satisfying stakeholder needs Keep learning Lots of Testing!!! Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 59 Pragmatic Test-Driven Development (core process) Tests written & must pass before checking in production code Write some Check if Re(write) production test fails a test code Clean up code (Refactor) 1 or more tests fail Check all tests succeed all tests succeed Ship Ready to it!!! Release? Short Sprints Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 60 TDD & Testing Best Practices Page - 30
  • 31. Joseph W. Yoder TDD Challenges 1. Lot’s of Unit Tests with classic TDD is not enough to guarantee good design… Dogmatic TDD can focus on functionality and features rather than design 2. Deception that incremental test mode will give you an inductive way to prove it works…probably more deductive and example driven… All squirrels I see in Illinois are brown, therefore all squirrels are brown…. 3. TDD or unit tests can hurt the evolution/refactoring phase….“Oh no! Changes might break the tests” 4. Not enough Quality Tests are written. Focus often is on function and missing quality. 5. Testing Patterns of Collaboration are important, Unit tests on class might not be good enough. Setting up Mocks doesn’t really test collaborations. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 61 Pragmatic Test Driven Development Is… Practical…  Focus on how testing best fits into and enhances your current software development practices. Thinking carefully about how best to validate that your software meets its requirements. Developing the optimum set of tests to feel confident your system keeps working, not just Unit Testing! Including both slow and fast thinking with your tests. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 62 TDD & Testing Best Practices Page - 31
  • 32. Joseph W. Yoder Keep It Focused Keep It Fresh Expand your Horizons …Be Practical Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 63 Where Did All The Time Go? Muito Obrigado!!! rebecca@wirfs-brock.com joe@refactory.com Twitter: @rebeccawb Twitter: @metayoda http://refactory.com/training/test-driven-development http://adaptiveobjectmodel.com/2012/01/what-is-pragmatic-tdd/ Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 64 TDD & Testing Best Practices Page - 32
  • 33. Joseph W. Yoder Minimum Bar for Pragmatic TDD All production code must have tests validating it. Think about tests early in each iteration and how to validate the next release. Core tests include important aspect of your software, what you really care about. Include both slow and fast thinking with your tests. Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 65 Ten Tenets of Testing 1. Test single complete scenarios 2. Do not create dependencies between tests 3. Only verify a single thing in each assertion 4. Respect class encapsulation 5. Test limit values and boundaries 6. Test expected exceptional scenarios 7. Test interactions with other objects 8. When you find a bug, write a test to show it 9. Do not duplicate application logic in tests 10. Keep your test code clean Pragmatic Test Driven Development – Copyright © 2012 Joseph W. Yoder The Refactory, Inc. Slide - 66 TDD & Testing Best Practices Page - 33