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 Slide

  2. View Slide

  3. THIS IS NOT
    ABOUT TDD!

    View Slide

  4. @ordepdev

    View Slide

  5. First of all
    Why testing?

    View Slide

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

    View Slide

  7. Testing is the
    engineering rigour of
    software development.

    View Slide

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

    View Slide

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

    View Slide

  10. Software
    Engineering

    View Slide

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

    View Slide

  12. MUCH MORE
    THAN CODING!

    View Slide

  13. Types of Bad
    Software Projects

    View Slide

  14. 1. Without tests.

    View Slide

  15. Zero Automated Tests.

    View Slide

  16. ZERO!

    View Slide

  17. Lack of
    professionalism?

    View Slide

  18. Lack of
    skills?

    View Slide

  19. Lack of
    knowledge?

    View Slide

  20. Lack of
    time to test?

    View Slide

  21. It can be all
    of them.

    View Slide

  22. What about
    software quality?

    View Slide

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

    View Slide

  24. View Slide

  25. 2. With Wrongly
    Designed Tests..

    View Slide

  26. Testing is
    HARD.

    View Slide

  27. View Slide

  28. Testing pitfalls:
    coupling.

    View Slide

  29. Implementation
    Boundary
    Testing
    Boundary

    View Slide

  30. Implementation
    Boundary
    Testing
    Boundary




    ✅ ✅




    View Slide

  31. Uncertainty
    and Doubt.

    View Slide

  32. Implementation
    Boundary
    Testing
    Boundary










    View Slide

  33. Testing pitfalls:
    performance.

    View Slide

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

    View Slide

  35. Types of
    Testing

    View Slide

  36. 1. Testing after the
    implementation.

    View Slide

  37. 2. Testing during
    the implementation.

    View Slide

  38. 3. Testing that
    reproduce bugs.

    View Slide

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

    View Slide

  40. But how?

    View Slide

  41. 5 rules.

    View Slide

  42. 1. Every change
    must have tests.

    View Slide

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

    View Slide

  44. Bugs in production
    are embarrassing
    and costly.

    View Slide

  45. 2. Write more
    than unit tests.

    View Slide

  46. Mutation
    testing!

    View Slide

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

    View Slide

  48. Property-based
    testing!

    View Slide

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

    View Slide

  50. Contract
    testing!

    View Slide

  51. View Slide

  52. Model-based
    testing!

    View Slide

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

    View Slide

  54. 3. Bug fixing
    must have tests.

    View Slide

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

    View Slide

  56. 4. Testing code
    must be reviewed.

    View Slide

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

    View Slide

  58. Testing code is
    production code!

    View Slide

  59. 5. Test suites
    must be consistent.

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  66. Wrapping up.

    View Slide

  67. “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 Slide

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

    View Slide

  69. ALWAYS BE
    AUTOMATING!

    View Slide

  70. GO AND FIX YOUR
    BROKEN CULTURE!

    View Slide

  71. TESTING
    building
    CULTURE

    View Slide