Writing Tests

#Summary

  • Tests need to be trusted.
  • Broken tests are worse than no tests.
  • False positives of tests reduce your trust in them.
  • More tests, means:

    • Code is harder to refactor.
    • Code is more rigid. Pros and cons.
  • Tests should be easily reproducible.

    • The harder it is to reproduce, the less likely they will run.
  • Tests need to run fast.

    • The longer they take to run

#Easily Reproducible

Tests should be easily reproducible.

Running a test should be as easy as:

./test.sh file --methods method

#Why People Don't Run/Write Tests

  • Writing good tests is a skill
  • Tests make your code more rigid.

    • Harder to refactor code.
  • Tests are too complicated to write.

    • Too much bootstrapping required.
  • Tests take to long to execute.
  • Tests cannot be trusted.
  • Tests need their own infrastruce and team to maintain.

    • Tests are like the IT Support of your code.
    • Good when they catch problems.
    • Waste of resources when nothing is done.

#Monitoring / Alerts

  • Can tests be easily disable globally?

    • For every engineer past a certain revision.
  • Which tests regularly fail?

    • On which revision did they fail?
  • Do you get alerts if a test fails?