Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How Much Should We Test?

How Much Should We Test?

Presented at SP Tech Talk

Michael Cheng

March 09, 2017
Tweet

More Decks by Michael Cheng

Other Decks in Programming

Transcript

  1. HOW MUCH SHOULD WE TEST?
    Or how to stop hating your tests

    View full-size slide

  2. GOALS OF TEST SUITE
    • Tests should be thorough
    • Tests should be stable
    • Tests should be fast
    • Tests should be few (minimal)

    View full-size slide

  3. TEST DRIVEN DEVELOPMENT
    • We use test cases to guide the design of our code
    • 2 approaches to testing - Inside Out and Outside In
    • Outside In - Use integration tests to guide you
    • Inside Out - Build & test individual components, integrate later

    View full-size slide

  4. Object under test

    View full-size slide

  5. Object under test
    Incoming Messages

    View full-size slide

  6. Object under test
    Incoming Messages Outgoing Messages

    View full-size slide

  7. Object under test
    Incoming Messages Outgoing Messages

    View full-size slide

  8. Object under test
    Incoming Messages Outgoing Messages
    Send to self

    View full-size slide

  9. Object under test
    Incoming Messages Outgoing Messages
    Send to self
    Message Types:

    View full-size slide

  10. Object under test
    Incoming Messages Outgoing Messages
    Send to self
    Query
    Message Types:

    View full-size slide

  11. Object under test
    Incoming Messages Outgoing Messages
    Send to self
    Command
    Query
    Message Types:

    View full-size slide

  12. MESSAGE TYPES
    • Query: Returns something / changes nothing
    • Command: Returns nothing / changes something
    Object under test
    Incoming Messages Outgoing Messages
    Send to self
    Command
    Query

    View full-size slide

  13. RESOURCES
    • “The Magic Tricks of Testing”
    - Sandi Metz

    http://confreaks.tv/videos/railsconf2013-
    the-magic-tricks-of-testing
    • “Working Effectively with
    Unit Tests” - Jay Fields

    https://leanpub.com/wewut

    View full-size slide