Skip to main content

Testing Strategy

Test Data Management: The Unglamorous Reason Your Suite Is Flaky

Marko KolasinacAug 8, 20263 min read
Test Data Management: The Unglamorous Reason Your Suite Is Flaky

Nobody budgets time for test data strategy. Every team budgets time for writing tests, and test data is treated as a detail that sorts itself out.

Right up until three tests are competing for the same user record and the suite fails differently depending on execution order.

The three ways shared data breaks a suite

  • Mutation collisions. Test A updates a user's email, Test B asserts the original email still exists. Whichever runs second fails, and which one runs second changes between CI runs.
  • Deletion races. A cleanup step in Test A deletes a record Test B hasn't finished reading yet, especially once tests run in parallel.
  • Accumulating cruft. Data created by a test that never got torn down builds up across runs, until pagination assertions that hardcoded "15 records" start failing because there are now 400.

None of these are flaky selectors or timing issues. They're data ownership problems that look like flakiness from the test report's point of view.

What actually fixes it

  1. Generate fresh data per test. A registration flow test that creates its own unique user, rather than reusing a shared login, can't collide with anything else in the suite. Our data-driven registration practice page is built around exactly this pattern: every run gets its own dataset.
  2. Tear down what you create, or run each test against a transaction that rolls back afterward. If teardown is unreliable, isolation was never real isolation.
  3. Never assert on absolute counts from data you don't fully control. Assert on relative changes ("one more record than before this test ran") so accumulated data from other tests doesn't break the assertion.
  4. Separate seed data from test-generated data. Seed data (reference values, fixed lookup tables) should be stable and shared. Anything a test creates during its own run should be scoped to that run and nothing else.

Where this pays off fastest

Parallel test execution is where data management problems go from occasional annoyance to constant failure, because tests that used to run sequentially and get lucky now genuinely race against each other. If you're speeding up a suite by parallelizing it and failures suddenly spike, check data isolation before you touch anything else. It's almost always the cause. This is one of the first things we audit in any test automation engagement, because it's invisible in a small suite and becomes the dominant source of flakiness the moment a suite scales.