How would you design a repeatable test for a suspected race condition?
Answer
Identify the shared state and competing operations, control synchronization to widen the critical interleaving, repeat with unique correlation data, and assert invariants. Capture timing and server evidence instead of relying only on random high concurrency.
Strong answer includes
- shared state and interleaving
- controlled synchronization
- asserts invariants
Practical example
To reproduce an intermittent double-booking bug, the tester inserts a controlled delay right before the database write in a test double, fires two concurrent booking requests for the same seat, and asserts that exactly one succeeds and one gets a conflict — turning a bug that appeared once every few hundred runs into one that reproduces every time.