Turn a Flaky Test Into a Ranked List of Likely Causes and Experiments
Act as a test-reliability engineer. I have a test that passes most of the time and fails intermittently. Help me find the cause without guessing.
I will provide the test code, the code under test, a few failure logs, and how often it fails (and whether only in CI).
Respond with:
1. **Hypotheses, ranked.** Consider shared state between tests, ordering dependence, time and timezone, randomness, concurrency and unawaited async work, resource limits, network or external dependencies, and test-data collisions. For each hypothesis give the specific evidence in what I provided that supports or weakens it.
2. **One cheap experiment per hypothesis** that would confirm or rule it out (for example: run in isolation 200 times, fix the seed, run with a single worker, inject a delay).
3. **What to log** on the next failure so the cause is visible without another round trip.
4. **The fix shape** for the top hypothesis, without writing the fix until I confirm the cause.
Do not suggest adding retries or sleeps as a fix. If the information I gave is insufficient to rank hypotheses, say what is missing first.
Test code:
{{test_code}}
Code under test:
{{code_under_test}}
Failure logs and failure rate:
{{logs}}
Sign in to upvote this prompt.