Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
ProgrammingMiddleOccasionalPractical

What problems can shared data structures cause during parallel test execution?

Answer

Mutable shared state can create races, order dependence, lost updates and failures that disappear when a test runs alone. Prefer isolated fixtures and unique data; when sharing is unavoidable, use concurrency-safe structures, explicit synchronization and atomic setup and cleanup with ownership that is easy to reason about. Stress the suite with repeated randomized parallel runs and capture worker, seed and timing information so failures remain reproducible.

Strong answer includes

  • recognizes races and order dependence
  • prefers isolation before synchronization
  • retains enough execution context to reproduce concurrency failures

Practical example

For example, two tests running in parallel both call a shared 'testUser' fixture and update the same 'balance' field — one test asserts balance equals 100 after a deposit while the other, running concurrently, has just withdrawn 50, so the first test flakes intermittently depending on execution order. Switching each test to create its own uniquely-named user via a factory function eliminates the interference entirely, and the team also starts logging the worker ID and random seed on failure so any remaining flake can be reproduced exactly.

#programming#parallelism#test-data#concurrency

Sources

Playwright best practicesMicrosoft · Reliable modern browser automationSelenium documentationSelenium Project · WebDriver architecture, waits, Grid and browser automation