Top 5 Test isolation Interview Questions
Browse 5 real-world technical and behavioral interview questions about Test isolation. Review scenarios, edge cases, and architectural best practices.
Your API suite runs on every commit against a shared database. How do you keep the tests from corrupting each other's data?
Make every test create its own preconditions under a generated identity, scope each assertion to records that test owns, and treat cleanup as housekeeping rather than as the isolation mechanism, because teardown does not run when a test is killed.
Your test suite fails randomly about one run in five. How do you get it under control?
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.
A test passes on its own and fails when the whole suite runs. How do you track that down?
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.
How do you run a Selenium suite in parallel across a grid without the tests interfering with each other?
Give each thread its own WebDriver session held in thread-local storage, remove every other piece of shared mutable state including test data and static fields, size the run to the grid's slots so requests queue rather than time out, and quit every session even on abnormal exit.
A test passes on your machine and fails in CI roughly once a week. How do you track it down?
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.