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 1 of 6
Twelve green tests for a discount function
builds on: What makes a test able to fail
You asked the agent to add tests for `discount`. It reports: *12 tests added, all green, 100% line coverage.* The tests run, touch every line and pass. But a test is only worth something if it can go red when the code is wrong. Before you count any of them, look at where each expected value came from.
Terms on this card
- line coverage
- The percentage of code lines executed while the tests run. It says nothing about whether any test checked the results.
- red
- A test or check that is failing.
- green
- A test or check that is passing.
- the agent
- The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
- coverage
- The share of code lines or branches executed by the tests. It says what ran, not whether the results were checked.
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