Skip to content
Preptima
mediumCodingConceptMidSenior

A test passes on its own and fails when the whole suite runs. How do you track that down?

5 min readUpdated 2026-08-15Target archetype: Big Tech, Enterprise Captive, Product Startup

Answer

Short answer

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.

Use testing as the diagnostic frame: the failure is not only that one assertion is red, it is that the test environment has hidden shared state. Good testing answers separate product behaviour from suite behaviour so the interviewer can see whether you would fix the code, the fixture, or the isolation boundary.

Was this answer helpful?

Likely follow-ups

  • Two workers run in parallel against one Postgres instance. What do you change, and what do you refuse to change?
  • The suite finishes but the process never exits. What is still open, and how do you find it?
  • How do you test code that reads the clock and has a 30-second timeout without the suite taking 30 seconds?
  • When is running serially the right permanent answer rather than a diagnostic step?

Related questions

Further reading