- All playbooks
- Check for leaks after this test cleans up
Check for leaks after this test cleans up
Run the leak check at the end of the test, where it inspects this test's own resources.
Company examples
How Uber used this technique
Read what Uber changed and follow the original sources.
Check for leaks after this test cleans up
Cadence moved goleak.VerifyNone from test entry into a deferred call in three election tests, so the check runs after the test body and its cleanup defers and inspects this test's goroutines.
The author reports that the flaky-test detector fired 5 times in CI from January through April 2026 and ten repeated race-enabled runs passing after the change. Source
- Use it when
- A cleanup assertion runs before the test allocates or releases the resources it is meant to inspect.
- Before applying it
- Understand defer ordering and asynchronous shutdown, and keep a final assertion that still catches an intentional leak.
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