AlgoViz

Write tests that disagree with broken code

hard 12 min

Choose assertions that can distinguish a correct service from a plausible defective one.

Theory

Read or listen first. About 1 min.

What it is

A generated reservation suite has forty tests. Each checks for a success response. A one-line change that debits one unit for a two-unit claim still passes all forty.

Why it exists

Write the expected response and the expected state separately. Derive the state from the requirement using literal quantities. Run the same assertion against a deliberately changed implementation. A surviving change identifies a blind spot; a killed change only demonstrates coverage of that particular fault.

One request, three implementations

ServiceReturned statusAfter reserving 2 of 3
Correctheld1 available
Always debit oneheld2 available
Response onlyheld3 available

Understand it

Work through the decision

A response assertion checks the client-facing contract but misses an incorrect write.

Pair it with a stored balance and a repeat operation. These observables catch more faults while keeping internal implementation details flexible.

Give the agent a check

  • Calculate a small example on paper and ask the assistant to find an implementation that satisfies the current tests but breaks that example.

The shortcut

  • Generate expected results by calling the helper used in the service.

What a reviewer can hear

SignalExample
WeakGenerate expected results by calling the helper used in the service.
CompetentThe independently calculated remaining balance of one, together with a successful hold.
StrongIt establishes sensitivity to this sample of faults. New policies and interleavings can introduce other failure modes.

Summary

The whole topic in one minute.

Change the code on purpose. Which test notices?

Sources