Mock dependencies for tests

Mock dependencies for tests in C++ — with the four heights of help laid out: do it now, make it easier for the next person to accept, work out the right move when you are stuck, and learn the pattern so it stops coming back.

4prompt heights
Open it in the interactive atlas →

The four heights

The same task, four distances: today's deadline, the next reviewer, the stuck moment, the pattern.

Execute — do the immediate task

+
I need test doubles for a NetworkClient dependency used by SyncService: provide a mock that can…
I need test doubles for a NetworkClient dependency used by SyncService: provide a mock that can simulate successful responses, timeouts, and HTTP 500 errors, and a fake that records requests and returns canned responses synchronously for deterministic unit tests. Show how to inject each into SyncService in tests and assert behavior on retry and backoff logic.

Improve — make it easier to accept

+
Before I add these mocks to the test suite, make them easy to review: put the failure modes…
Before I add these mocks to the test suite, make them easy to review: put the failure modes (timeout, server error, malformed payload) up top, make the canned responses findable, flag where behavior diverges between the mock and the real client (threading, latencies), and suggest one small change to make the mock reusable across other services.

Decide — diagnose the stuck moment

+
I built a mock NetworkClient that returns an error code to simulate a timeout, but SyncService's…

My mock doesn't trigger retry code under simulated timeouts

I built a mock NetworkClient that returns an error code to simulate a timeout, but SyncService's retry logic does not run during the test. I need to say what I implemented, which tests fail, who expects retries, and what I fear (the mock not matching the client's failure semantics or missing async scheduling). What's the likely cause and the best fix so tests exercise the retry logic correctly?

Become — change the pattern

+
Across the codebase, every team writes their own ad hoc mocks for network and storage clients, and…

We keep writing bespoke mocks per test that diverge from real behavior

Across the codebase, every team writes their own ad hoc mocks for network and storage clients, and they slowly drift from the real clients' behavior, causing false confidence in tests. Which habit should I change to prevent this: recommend a shared mock/fake library with canonical failure modes, a periodic sync test against a real client, and one enforcement rule in reviews to keep mocks honest.

Next to this one

Other programming language work people do in C++.

Every task here came from the work, not from a feature list — which is why the prompts name what you want done and never the button that does it. The tool changes; the work does not.
Copyright © LLOS.ai · 2026 — original pedagogy, voice, and design — all rights reserved.

The rest of the map

Same library, five ways in.