Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
What makes a test able to fail
card 4 of 6
Same formula, same bug
The spec says shipping is free for orders of 50 or more. The code uses `>`, so an order of exactly 50 pays 5.
The BAD test computes its oracle with the same `t > 50` expression. It agrees with the bug and stays green.
The BETTER test takes `0` straight from the spec at the boundary. It goes red against this code and exposes the bug. The `49` case pins down the other side of the boundary.
// Python
# spec: free shipping for orders >= 50
def fee(total):
return 0 if total > 50 else 5
# BAD
def test_fee():
t = 50
assert fee(t) == (0 if t > 50 else 5)
# BETTER
def test_fee_at_threshold():
assert fee(50) == 0
assert fee(49) == 5
Terms on this card
- oracle
- The expected result a test compares the code's actual output against; it decides pass or fail.
- spec
- Specification: the stated requirements for what the code should do, e.g. a ticket, design doc or agreed rules.
- green
- A test or check that passes.
- red
- A test or check that fails.
- boundary
- The input value where behaviour changes, such as exactly 50 for 'orders of 50 or more'; a common place for bugs.
Lesson goal: Explain a test as inputs plus an oracle, the expected result. The oracle must come from the specification rather than from the code under test. A test that cannot go red when the code is wrong proves nothing. ·
the whole lesson