Building a testing culture

Building a testing culture

074c1726aee7c73df923c3d5064ab861?s=128

Pedro Tavares

June 02, 2018
Tweet

Transcript

  1. TESTING building CULTURE

  2. https://ordepdev.me/posts/test-driven-developers

  3. THIS IS NOT ABOUT TDD!

  4. @ordepdev

  5. First of all Why testing?

  6. “It’s time for software developers to take up the mantle

    of responsibility for what they produce.
  7. Testing is the engineering rigour of software development.

  8. Responsibility — the state or fact of being accountable or

    to blame for something.
  9. Rigour — the quality of being extremely thorough and careful.

  10. Software Engineering

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

    software production.
  12. MUCH MORE THAN CODING!

  13. Types of Bad Software Projects

  14. 1. Without tests.

  15. Zero Automated Tests.

  16. ZERO!

  17. Lack of professionalism?

  18. Lack of skills?

  19. Lack of knowledge?

  20. Lack of time to test?

  21. It can be all of them.

  22. What about software quality?

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

  24. None
  25. 2. With Wrongly Designed Tests..

  26. Testing is HARD.

  27. https://twitter.com/codepipes/status/987934900111138816

  28. Testing pitfalls: coupling.

  29. Implementation Boundary Testing Boundary

  30. Implementation Boundary Testing Boundary ✅ ✅ ✅ ✅ ✅ ✅

    ✅ ✅ ❌ ❌
  31. Uncertainty and Doubt.

  32. Implementation Boundary Testing Boundary ✅ ✅ ✅ ✅ ✅ ❌

    ❌ ❌ ❌ ❌
  33. Testing pitfalls: performance.

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

  35. Types of Testing

  36. 1. Testing after the implementation.

  37. 2. Testing during the implementation.

  38. 3. Testing that reproduce bugs.

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

  40. But how?

  41. 5 rules.

  42. 1. Every change must have tests.

  43. 50 100 150 200 Development Unit Tests Functional Tests System

    Tests Production The cost of bugs
  44. Bugs in production are embarrassing and costly.

  45. 2. Write more than unit tests.

  46. https://twitter.com/pwlporto/status/999258562370170880

  47. We do not know how much an increase in coverage

    can decrease the number of defects.” “
  48. https://ordepdev.me/posts/code-coverage

  49. Mutation testing!

  50. def add(x,y) x + y end def add(x,y) x -

    y end Source Code Mutation
  51. Property-based testing! https://hypothesis.works/articles/quickcheck-in-every-language

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

  53. Contract testing! https://martinfowler.com/bliki/ContractTest.html

  54. https://ordepdev.me/posts/boost-your-confidence-with-consumer-driven-contracts

  55. Model-based testing! http://mit.bme.hu/~micskeiz/pages/modelbased_testing.html

  56. Instead of writing hundreds of test cases, write an abstract

    model of the system and generate a set of test cases.” “
  57. None
  58. Formal methods! https://www.infoq.com/presentations/aws-testing-tla

  59. Formal methods use mathematical proof as a complement to system

    testing in order to ensure correct behavior.” “
  60. 3. Bug fixing must have tests.

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

  62. 4. Testing code must be reviewed.

  63. A well-designed test suite is much easier to read, understand

    and evolve.
  64. Testing code is production code!

  65. 5. Test suites must be consistent.

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

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

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

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

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

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

    tools.
  72. 5+1.Test suites must be visible.

  73. A failed test is a failed build!

  74. Wrapping up.

  75. 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. “ ”
  76. Manual work is a bug. acmqueue | january-february 2018

  77. ALWAYS BE AUTOMATING!

  78. GO AND FIX YOUR BROKEN CULTURE!

  79. TESTING building CULTURE @ordepdev ordepdev.me Thanks!