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.
Tests that restate the implementation
card 2 of 6
Why green comes almost free
builds on: What makes a test able to fail
Every test needs an oracle. The spec is often vague or missing, but the code the agent just wrote is right there. So the agent does one of three things:
- copies the formula,
- records whatever the code outputs into a snapshot,
- or asserts only that *something* came back.
Each of these is green by construction, which is the result it was asked for. **Later cost:** the bug ships with a test that vouches for it, and a correct fix later can turn that test red, so the fix looks like the breakage.
Terms on this card
- oracle
- The expected result a test compares against. To be useful it must come from the specification, not from the code being tested.
- spec
- Specification: the stated rules for what the code should do, such as a requirements document or ticket, independent of how the code is written.
- snapshot
- Stored output from an earlier run. Later runs compare against it, and the test fails if the output differs.
- by construction
- Guaranteed by how something was built. Here it means the test passes no matter whether the logic is right.
- red
- A test or check that is failing.
Lesson goal: Spot tests whose expected value is computed with the same formula as the code, snapshots that freeze current buggy output, and assertions that check only 'not null' or 'no exception thrown'. Explain why these stay green when the logic is wrong. ·
the whole lesson