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.
Test doubles: stubs, fakes, mocks and spies
card 1 of 6
Green tests around a payment call
You asked the agent to add tests for `checkout()`, which charges a card through a payment gateway. A minute later it reports a green suite and says checkout is "fully tested". Every test replaces the gateway with a stand-in. Before you trust that green, ask two things. What kind of stand-in is it? What could go wrong in `checkout()` that this test would never notice?
Terms on this card
- payment gateway
- An external service that actually charges a customer's card when your code asks it to.
- green suite
- A set of tests that all pass.
- the agent
- The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
- green
- A test or check that passes.
- suite
- All the tests of a project, run together.
Lesson goal: Distinguish the four kinds of test double: stubs return canned answers, fakes are working lightweight implementations, mocks verify interactions and spies record calls. Say what each kind lets a test verify, and what it lets a test silently skip. ·
the whole lesson