MEPX
Chapter 8 of 10All chapters

Chapter 8 of 10

Tests as documentation

The clearest statement of intent.

Read the tests first

Tests show how the author expected the code to be called and what they considered correct. They are usually the fastest description of behaviour available.

  • Test names often state the rules in plain language.
  • Missing tests around an area tell you where the fear is.

Write one to learn

Adding a test for behaviour you think you understand is the cheapest way to check. If it fails, your model was wrong and you have learned something specific.