- All playbooks
- Slow tests
- Keep unit tests independent of slow services
Keep unit tests independent of slow services
Use controlled substitutes for external dependencies when the test is intended to verify local behavior, keeping integration coverage separately.
How companies used this technique
Read what each company changed and follow the original sources.
Mock the slow dependency
OpenAI added a missing mock to a 63-test resolver suite and kept all 63 tests. In the public evals repository, the workflow validates new evaluations against dummy chat and completion models, so the check runs without a live model call.
63-test resolver suite: 592.6s to 29.8s after adding the missing mock Source
- Use it when
- A slow test calls a real dependency outside the code it exists to verify.
- Before applying it
- Keep one job that exercises the real dependency, nightly or after merge. A deterministic mock proves the code under test, and the live job proves the service.
Keep unit tests independent of database servers
Cadence removed Cassandra, MySQL, PostgreSQL and MongoDB services from its unit-test container. Component tests that only needed persistence switched to SQLite, and database-specific persistence and CLI tests moved into the integration tree, whose Makefile gained an explicit discovery pass. OPT87's boundary-isolation recipe is adapted with a local SQLite store.
The PR reports unit and integration test runs and a comparison of coverage reports. Source
- Use it when
- Unit or component checks wait for database servers whose engine-specific behavior they never exercise.
- Before applying it
- Keep real-engine integration tests and compare their discovered test sets and combined coverage, since unit-only coverage shifts when tests move. The server-startup test also drops a Cassandra schema-version assertion; keep an equivalent engine-specific check in the integration lane.
Company Playbooks
- Read Anthropic’s playbookRun only affected tests
- Read DoorDash’s playbookRun build and test in parallel, sharded across CI agents
- Read Linear’s playbookBenchmark the same job on faster hardware
- Read Mastra’s playbookStarSling runners for the slowest test workflow
- Read OpenAI’s playbookRank CI fixes by the minutes they save
- Read Ramp’s playbookMove a CPU-bound test suite to a faster CPU
- Read Shopify’s playbookLet an agent iterate against one CI metric
- Read Spotify’s playbookBuild arm64 on native arm64 runners
- Read Stripe’s playbookRun only the tests a change can reach
- Read Uber’s playbookBuild the merge-queue speculations most likely to be needed