Test data management
Factories and builders over shared fixtures, per-test isolation, seeding via API/DB, synthetic PII (a DPDP concern in India). Shared mutable data is the #1 cause of order-dependent tests.
The mental model
A professional kitchen runs on mise en place: every cook gets their own prepped ingredients, laid out before service starts, and nobody reaches into a colleague's station mid-dish. Test data management is mise en place for automation. Every test gets its own user, its own order, its own rows — created just before the test, shaped exactly for the scenario, and cleared away after. The alternative — one big shared pantry that every test raids and mutates — is how you get the suite equivalent of two cooks fighting over the last onion: tests that pass alone and fail together, pass on Monday and fail on Friday, pass in order and fail shuffled.
Why this discipline exists: **shared mutable data is the number-one cause of order-dependent and parallel-unsafe tests.** A test that logs in as testuser@example.com and edits "the first order in the list" makes two silent assumptions — that the user's state is what the last run left behind, and that no other worker is touching it right now. Run at workers=4 and both assumptions break. The symptoms never say "data problem"; they say "element not found," "expected 3 items, got 7," "409 Conflict" — which is why teams chase them as locator bugs for weeks.
The second reason it exists is legal, and in India it now has teeth: the DPDP Act treats personal data in test environments as personal data, full stop. A production dump restored into a staging database that fifty engineers and three vendors can query is a data-protection incident that has not been discovered yet. Synthetic data is not a nice-to-have; it is the compliance default.
The senior-level frame: test data has a lifecycle — generate, seed, use, tear down — and a scope — per-suite, per-worker, per-test. Getting both right is what makes a suite parallel-safe; getting either wrong is what makes it flaky in ways no locator fix can cure.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision