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

BAD: what the agent wrote

builds on: Test doubles: stubs, fakes, mocks and spies, What makes a test able to fail
Test 1 replaces `discount`, a method of the very object under test, so the real rule never runs. It then checks only that calls happened and ignores the result of `total`. Test 2 calls the mock and asserts it returned `[50, 50]`, the value set one line earlier. Change the discount to 20 off and neither test goes red. Both also stay green if `total` adds wrongly or never returns its result.
// Python  BAD
def test_total_applies_discount():
    repo = Mock()
    repo.cart.return_value = [50, 50]
    co = Checkout(repo)
    co.discount = Mock(return_value=10)
    co.total("u1")
    repo.cart.assert_called_once_with("u1")
    co.discount.assert_called_once()

def test_repo_returns_cart():
    repo = Mock()
    repo.cart.return_value = [50, 50]
    assert repo.cart("u1") == [50, 50]
Terms on this card
mock
A test double that is preconfigured with answers and checks which calls it received.
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.
green
A test or check that passes.
set
Python collection that stores items by hash, so checking membership with `in` takes constant time on average.
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