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

Listening to the tests

Hibri Marzook
September 13, 2012

Listening to the tests

A talk on what the practicing TDD tells you about how you, the team and the software you build

Hibri Marzook

September 13, 2012
Tweet

More Decks by Hibri Marzook

Other Decks in Programming

Transcript

  1. Listening to the tests
    Hibri Marzook
    @hibri
    [email protected]
    1
    Thursday, 13 December 12

    View Slide

  2. What do tests tell us ?
    • What other things than a red or a green do
    tests tell us ?
    • How do we know TDD is working for us ?
    2
    Thursday, 13 December 12

    View Slide

  3. The Testing Triangle
    3
    Thursday, 13 December 12

    View Slide

  4. Before you write a test
    4
    Thursday, 13 December 12

    View Slide

  5. Before you write a test
    • Can you run your tests, after a clean checkout and
    get a green bar ?
    4
    Thursday, 13 December 12

    View Slide

  6. Before you write a test
    • Can you run your tests, after a clean checkout and
    get a green bar ?
    • If you have to fiddle with other things before you
    run tests, your time to get feedback is increased
    4
    Thursday, 13 December 12

    View Slide

  7. Before you write a test
    • Can you run your tests, after a clean checkout and
    get a green bar ?
    • If you have to fiddle with other things before you
    run tests, your time to get feedback is increased
    • How many times do you have to ask others “who is
    running tests on the dev server ? “
    4
    Thursday, 13 December 12

    View Slide

  8. Before you write a test
    • Can you run your tests, after a clean checkout and
    get a green bar ?
    • If you have to fiddle with other things before you
    run tests, your time to get feedback is increased
    • How many times do you have to ask others “who is
    running tests on the dev server ? “
    • Do you have a build token when checking in?
    4
    Thursday, 13 December 12

    View Slide

  9. Before you write a test
    • Can you run your tests, after a clean checkout and
    get a green bar ?
    • If you have to fiddle with other things before you
    run tests, your time to get feedback is increased
    • How many times do you have to ask others “who is
    running tests on the dev server ? “
    • Do you have a build token when checking in?
    • Do you have to tell your QA to stop testing while
    you deploy ?
    4
    Thursday, 13 December 12

    View Slide

  10. While writing
    • Writing a new test, in a green field
    project is easy.
    • Writing for existing code is hard
    5
    Thursday, 13 December 12

    View Slide

  11. Test smells
    6
    Thursday, 13 December 12

    View Slide

  12. Test smells
    • Too many expectations, asserts in one test
    6
    Thursday, 13 December 12

    View Slide

  13. Test smells
    • Too many expectations, asserts in one test
    • Mocktastic tests.
    6
    Thursday, 13 December 12

    View Slide

  14. Test smells
    • Too many expectations, asserts in one test
    • Mocktastic tests.
    • Large setup methods
    6
    Thursday, 13 December 12

    View Slide

  15. Test smells
    • Too many expectations, asserts in one test
    • Mocktastic tests.
    • Large setup methods
    • Copy and pasting tests
    6
    Thursday, 13 December 12

    View Slide

  16. Test smells
    • Too many expectations, asserts in one test
    • Mocktastic tests.
    • Large setup methods
    • Copy and pasting tests
    • Teardown methods
    6
    Thursday, 13 December 12

    View Slide

  17. Test smells
    • Too many expectations, asserts in one test
    • Mocktastic tests.
    • Large setup methods
    • Copy and pasting tests
    • Teardown methods
    • Duplication between test fixtures
    6
    Thursday, 13 December 12

    View Slide

  18. Writing tests
    7
    Thursday, 13 December 12

    View Slide

  19. Writing tests
    • Tests are complex when the underlying code is
    complex
    7
    Thursday, 13 December 12

    View Slide

  20. Writing tests
    • Tests are complex when the underlying code is
    complex
    • Symptoms : mockery, complex setup, too many tests
    per unit
    7
    Thursday, 13 December 12

    View Slide

  21. Writing tests
    • Tests are complex when the underlying code is
    complex
    • Symptoms : mockery, complex setup, too many tests
    per unit
    • Writing a test should be easy, if it is hard, the code
    being tested could be complex.
    7
    Thursday, 13 December 12

    View Slide

  22. Writing tests
    • Tests are complex when the underlying code is
    complex
    • Symptoms : mockery, complex setup, too many tests
    per unit
    • Writing a test should be easy, if it is hard, the code
    being tested could be complex.
    • Complex code can be written even when doing TDD.
    7
    Thursday, 13 December 12

    View Slide

  23. Writing tests
    • Tests are complex when the underlying code is
    complex
    • Symptoms : mockery, complex setup, too many tests
    per unit
    • Writing a test should be easy, if it is hard, the code
    being tested could be complex.
    • Complex code can be written even when doing TDD.
    • When you are having a hard time writing a test, pay
    attention to the code.
    7
    Thursday, 13 December 12

    View Slide

  24. After running tests
    8
    Thursday, 13 December 12

    View Slide

  25. After running tests
    • How long do they run for ?
    8
    Thursday, 13 December 12

    View Slide

  26. After running tests
    • How long do they run for ?
    • Do they fail for the right reasons ?
    8
    Thursday, 13 December 12

    View Slide

  27. After running tests
    • How long do they run for ?
    • Do they fail for the right reasons ?
    • Do you have to parse a stack trace in
    your head to find out why your tests
    failed ?
    8
    Thursday, 13 December 12

    View Slide

  28. After running tests
    9
    Thursday, 13 December 12

    View Slide

  29. After running tests
    • How many tests do you have?
    9
    Thursday, 13 December 12

    View Slide

  30. After running tests
    • How many tests do you have?
    • How long did they take ?
    9
    Thursday, 13 December 12

    View Slide

  31. After running tests
    • How many tests do you have?
    • How long did they take ?
    • Watch the stats
    9
    Thursday, 13 December 12

    View Slide

  32. To end..
    10
    Thursday, 13 December 12

    View Slide

  33. To end..
    • Think about what value your tests are giving you ?
    10
    Thursday, 13 December 12

    View Slide

  34. To end..
    • Think about what value your tests are giving you ?
    • Are they giving you the feedback you need ?
    10
    Thursday, 13 December 12

    View Slide

  35. To end..
    • Think about what value your tests are giving you ?
    • Are they giving you the feedback you need ?
    • Are they helping you deliver faster and reliably ?
    10
    Thursday, 13 December 12

    View Slide

  36. To end..
    • Think about what value your tests are giving you ?
    • Are they giving you the feedback you need ?
    • Are they helping you deliver faster and reliably ?
    • Does your team see tests are a chore or as an aid ?
    10
    Thursday, 13 December 12

    View Slide

  37. To end..
    • Think about what value your tests are giving you ?
    • Are they giving you the feedback you need ?
    • Are they helping you deliver faster and reliably ?
    • Does your team see tests are a chore or as an aid ?
    • If you are not getting the benefits of TDD, don’t do it.
    10
    Thursday, 13 December 12

    View Slide

  38. To end..
    • Think about what value your tests are giving you ?
    • Are they giving you the feedback you need ?
    • Are they helping you deliver faster and reliably ?
    • Does your team see tests are a chore or as an aid ?
    • If you are not getting the benefits of TDD, don’t do it.
    • Do something else that will let you deliver faster and
    reliably.
    10
    Thursday, 13 December 12

    View Slide

  39. To end..
    • Think about what value your tests are giving you ?
    • Are they giving you the feedback you need ?
    • Are they helping you deliver faster and reliably ?
    • Does your team see tests are a chore or as an aid ?
    • If you are not getting the benefits of TDD, don’t do it.
    • Do something else that will let you deliver faster and
    reliably.
    • If you do, I’d like to know what it is.
    10
    Thursday, 13 December 12

    View Slide

  40. Questions and your
    views
    11
    Thursday, 13 December 12

    View Slide