In everyday life
Like a food inspector who tastes the soup and checks its temperature, not which spoon the cook used. A new spoon should not fail the inspection.
One case
A ride-sharing app’s fare function has 12 tests. A developer rewrites its inside to make it faster, and every fare it returns stays the same. 9 of the 12 tests fail, because they checked which helper ran and in what order. The developer spends a day fixing tests that found no bug.
Every case
A test is a claim about what the code does for its users. Judge it with two imagined edits. Break the result: a good test fails. Rewrite the inside and keep every result the same: a good test still passes. A test with an assertionThe line in a test that states what must be true, such as “the fare is $12.40”. about the inside does the opposite. It breaks on every rewrite and often misses real bugs, so people learn to fear change and to ignore red.
The word
Engineers call this
Test what the code does, not how it does it. A good test fails when the result breaks and survives a rewrite of the inside.