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 1 of 6

Green tests, nothing checked

builds on: Test doubles: stubs, fakes, mocks and spies, What makes a test able to fail
You asked the agent to add tests for `Checkout.total`. The rule: orders over 100 get 10 off. The agent reports: “Added 2 tests, all green, `total` fully covered.” The diff is full of `Mock()` objects and `assert_called_once_with`. Coverage, the share of lines the tests run, did go up. Now suppose someone changes the discount to 20 off by mistake. Would either test go red?
Terms on this card
mock
A test double that is preconfigured with answers and checks which calls it received.
coverage
The share of code lines executed by the tests. It says nothing about whether anything was checked.
Mock()
Python's unittest.mock object. Any attribute or call on it returns another mock, or the value you configured.
assert_called_once_with
Python mock assertion that the mock was called exactly once with the given arguments. It checks the call, not the result.
the agent
The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
Learn this step by step on Bytewise
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