Verifying correctness.
WHAT LEVELS EXIST
Unit tests, covering individual pieces Integration tests, covering pieces working together End-to-end tests, covering whole paths
WHAT PROPORTIONS SUIT MOST PROJECTS
Many unit tests, fewer integration tests, few end-to-end tests.
WHY
Unit tests are fast and precise; end-to-end tests are slow and fragile.
WHAT MAKES A GOOD TEST
It tests behaviour, not implementation It fails for one reason Its name says what it verifies It does not depend on other tests
WHY BEHAVIOUR NOT IMPLEMENTATION
Tests coupled to implementation break on every refactor and prevent improvement.
WHAT TO TEST FIRST
The paths that matter most, and everything that has broken before.
WHY THAT SECOND ONE
A test for a fixed bug prevents its return.
WHAT TO SUBSTITUTE
External dependencies: networks, databases, time, randomness.
WHY TIME AND RANDOMNESS
Otherwise tests fail intermittently, and intermittent tests get ignored.
WHAT COVERAGE MEASURES
Which code ran during tests.
WHAT IT DOES NOT MEASURE
Whether the tests verify anything useful.
WHAT TO RUN AUTOMATICALLY
Everything, on every change.