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.
Mocks that test nothing
card 2 of 6
Why mocks drift into testing themselves
builds on: Test doubles: stubs, fakes, mocks and spies, What makes a test able to fail
When the agent runs tests, the only feedback it gets is red or green. A test that can never go red looks exactly like a good test in that feedback. Real collaborators, such as storage or a payment gateway, are awkward to set up. So the agent mocks them, and sometimes the logic itself, until everything is green on the first try. The tests become a proxy signal: they run lines and raise coverage but check nothing. **Later cost:** the suite stays green while `total` charges the wrong amount, and every later change to `total` looks safe.
Terms on this card
- proxy signal
- A visible stand-in for the real goal, such as tests being green, that can be satisfied without reaching the goal.
- coverage
- The share of code lines executed by the tests. It says nothing about whether anything was checked.
- the agent
- The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
- red
- A test or check that is failing. Green means passing.
- payment gateway
- An external service that actually charges a customer's card when your code asks it to.
Lesson goal: Recognise tests that mock the unit under test, assert that a mock returned what it was configured to return, or check only that calls happened without checking any outcome. Rewrite such a test to exercise real logic, using fakes where possible. ·
the whole lesson