Testing

A test suite is a claim about the code, and it can be wrong in both directions: red when nothing is broken, green when something is. Each lesson here shows a test that lies, then the change that makes it tell the truth.

01
FLAKY TEST FROM A RACE
A sleep is a guess about how long the other thread takes
L215 MIN
02
ORDER-DEPENDENT TESTS
Green in file order, red when shuffled
L112 MIN
03
The mock that lied
Green unit tests against a provider that no longer exists
L216 MIN
04
100% coverage, bug intact
Every line ran. Nothing checked the answer.
L217 MIN
05
BOUNDARY VALUES
Bugs live on the edge of a rule, so put a test on the edge
L112 MIN
06
PROPERTY-BASED TESTING
State what must always hold, then let the machine hunt for the input that breaks it
L216 MIN
07
TIME IN TESTS
A test that reads the clock passes on the day it was written
L215 MIN
08
RETRIES HIDE THE BUG
A pass on the second try is still a failure
L216 MIN
09
Eventual Consistency in Assertions
The sleep that fixed the flaky test until the replica got busy
L215 MIN
10
Snapshot Tests
The 400-line diff nobody reads before pressing update
L112 MIN
11
TEST SELECTION
Run the tests that depend on the change, not the tests next to it
L215 MIN
12
DETERMINISTIC SIMULATION
Run the distributed system under a scheduler you can replay
L320 MIN
13
CAPSTONE: THE GREEN SUITE
Three bugs, a green build and a 25-minute wait
L322 MIN