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

Building a testing culture

Building a testing culture

Pedro Tavares

May 10, 2018
Tweet

More Decks by Pedro Tavares

Other Decks in Programming

Transcript

  1. TESTING
    building
    CULTURE

    View full-size slide

  2. THIS IS NOT
    ABOUT TDD!

    View full-size slide

  3. First of all
    Why testing?

    View full-size slide

  4. “It’s time for software
    developers to take up the
    mantle of responsibility
    for what they produce.

    View full-size slide

  5. Testing is the
    engineering rigour of
    software development.

    View full-size slide

  6. Responsibility
    — the state or fact of being
    accountable or to blame for
    something.

    View full-size slide

  7. Rigour
    — the quality of being extremely
    thorough and careful.

    View full-size slide

  8. Software
    Engineering

    View full-size slide

  9. An engineering discipline
    that is concerned with
    all aspects of software
    production.

    View full-size slide

  10. MUCH MORE
    THAN CODING!

    View full-size slide

  11. Types of Bad
    Software Projects

    View full-size slide

  12. 1. Without tests.

    View full-size slide

  13. Zero Automated Tests.

    View full-size slide

  14. Lack of
    professionalism?

    View full-size slide

  15. Lack of
    skills?

    View full-size slide

  16. Lack of
    knowledge?

    View full-size slide

  17. Lack of
    time to test?

    View full-size slide

  18. It can be all
    of them.

    View full-size slide

  19. What about
    software quality?

    View full-size slide

  20. Relax, they test
    all features with
    manual testing.

    View full-size slide

  21. 2. With Wrongly
    Designed Tests..

    View full-size slide

  22. Testing is
    HARD.

    View full-size slide

  23. Testing pitfalls:
    coupling.

    View full-size slide

  24. Implementation
    Boundary
    Testing
    Boundary

    View full-size slide

  25. Implementation
    Boundary
    Testing
    Boundary




    ✅ ✅




    View full-size slide

  26. Uncertainty
    and Doubt.

    View full-size slide

  27. Implementation
    Boundary
    Testing
    Boundary










    View full-size slide

  28. Testing pitfalls:
    performance.

    View full-size slide

  29. Taking
    too much time?
    — that’s a no run.

    View full-size slide

  30. Types of
    Testing

    View full-size slide

  31. 1. Testing after the
    implementation.

    View full-size slide

  32. 2. Testing during
    the implementation.

    View full-size slide

  33. 3. Testing that
    reproduce bugs.

    View full-size slide

  34. It’s our job to
    build a testing
    culture!

    View full-size slide

  35. 1. Every change
    must have tests.

    View full-size slide

  36. 50
    100
    150
    200
    Development Unit Tests Functional Tests System Tests Production
    The cost of bugs

    View full-size slide

  37. Bugs in production
    are embarrassing
    and costly.

    View full-size slide

  38. 2. Write more
    than unit tests.

    View full-size slide

  39. Mutation
    testing!

    View full-size slide

  40. def add(x,y)
    x + y
    end
    def add(x,y)
    x - y
    end
    Source Code Mutation

    View full-size slide

  41. Property-based
    testing!

    View full-size slide

  42. http://blog.jessitron.com/2013/04/property-based-testing-what-is-it.html

    View full-size slide

  43. Contract
    testing!

    View full-size slide

  44. Model-based
    testing!

    View full-size slide

  45. Try formal
    methods!
    https://www.infoq.com/presentations/aws-testing-tla

    View full-size slide

  46. 3. Bug fixing
    must have tests.

    View full-size slide

  47. Don’t repeat the
    same bug hunting
    — write a test!

    View full-size slide

  48. 4. Testing code
    must be reviewed.

    View full-size slide

  49. A well-designed test
    suite is much easier to
    read, understand and
    evolve.

    View full-size slide

  50. Testing code is
    production code!

    View full-size slide

  51. 5. Test suites
    must be consistent.

    View full-size slide

  52. L12. assertEquals(input, expectation);
    L35. assertEquals(expectation, input);
    L43. assertThat(input).isEqualTo( expectation);
    Assertions

    View full-size slide

  53. L12. assertEquals(input, expectation);
    L35. assertEquals(expectation, input);
    L43. assertThat(input).isEqualTo( expectation);
    Assertions

    View full-size slide

  54. L12. createEntity
    L35. create_withValidPayload_success
    L43. create_withValidPayload_shouldPersistEntity
    Test Methods

    View full-size slide

  55. L12. createEntity
    L35. create_withValidPayload_success
    L43. create_withValidPayload_shouldPersistEntity
    Test Methods

    View full-size slide

  56. We must share
    the same values,
    practices, and tools.

    View full-size slide

  57. Enforce them through code
    reviews, static analysis, and
    style checking tools.

    View full-size slide

  58. Wrapping up.

    View full-size slide

  59. “People who are successful at
    automating tasks tend to work
    this way in every aspect of their
    jobs. It is just how they work; it
    is part of their culture.”

    View full-size slide

  60. Manual work
    is a bug.
    acmqueue | january-february 2018

    View full-size slide

  61. ALWAYS BE
    AUTOMATING!

    View full-size slide

  62. GO AND FIX YOUR
    BROKEN CULTURE!

    View full-size slide

  63. TESTING
    building
    CULTURE

    View full-size slide