Loading...
Loading...
Browse 4 real-world technical and behavioral interview questions about Flaky tests. Review scenarios, edge cases, and architectural best practices.
Quarantine and measure before fixing: keep per-test pass history so you can rank offenders and restore a trustworthy signal, then work the root-cause families one at a time. Retries belong in a narrow, logged, budgeted policy, because a blanket rerun turns a real product race condition into a green build.
The failing test is a victim, not the cause: something earlier mutated state it shares, usually a module evaluated once, a global that was patched and not restored, or rows left in a database. Bisect the ordering to find the pair, then remove the sharing.
Make time and scheduling injectable. Take a java.time.Clock as a dependency so a test can fix it, and replace a fixed sleep with a bounded poll on the observable outcome, so a fast machine does not wait and a slow one does not fail.
Make it reproducible before you make it pass. Pin the ordering seed, then work through the sources of non-determinism the test is exposed to - wall-clock time, global random state, hash-dependent iteration, real network calls and shared resources - and inject each one so the test controls it.