CodeCrafting All articles
Build & Delivery

Nobody's Real Here: Building Test Data That Doesn't Borrow the Nation's Records

CodeCrafting
Nobody's Real Here: Building Test Data That Doesn't Borrow the Nation's Records

Photo: NASA Johnson Space Center, Public domain, via Wikimedia Commons

The request arrives on a Thursday afternoon, usually by direct message: can someone dump the customer table into staging? It's a small ask. It's also the start of a chain that ends, sooner or later, in someone scrolling through a spreadsheet of real names and addresses wondering whether this counts as a personal data breach.

Production copies win because they are free, immediate and realistic. They are also a liability you can't inventory: the copy nobody remembers, the backup of the copy, the exported CSV on a laptop, the column added last quarter that the anonymisation script never learned about.

Synthetic data is the alternative, and it's better than most teams assume — provided you do the cataloguing work that makes it representative.

What "representative" actually means

You do not need a million rows to test a form. You need the rows that break things. In most UK systems that's a specific, finite, slightly eccentric list:

None of that requires a real customer. All of it requires somebody to have written it down.

Keep an edge case register

Before you build a generator, build a list. A single file in the repository, edge-cases.md, with an entry per case: what it is, why it matters, which test covers it, and — the useful bit — a link to the incident or bug that taught you. The file grows every time something breaks in a way that traces back to a shape of data nobody thought of.

That register is the actual asset. Generators are replaceable; the knowledge of what your system finds difficult is not.

Generate, don't launder

A generator is code. Treat it like code: version it, review it, run it in CI, and seed it so the same seed produces the same dataset. That determinism matters — a failing test that only fails on some builds because the fixture generator rolled different dice is a week of somebody's life.

A practical shape:

  1. A small, hand-curated fixture set for unit tests, covering every entry in the register.
  2. A bulk generator for performance and integration environments, parameterised by volume and profile.
  3. Profiles that mimic distributions — a realistic spread of surname lengths, address formats and postcode areas — rather than uniform noise.
  4. A version number printed at start-up so anyone looking at an environment knows exactly which dataset it holds.

Make the generated data obviously fake where it can be. Reserved example domains, numbers in the 07700 900xxx range, and names that are clearly invented remove any chance of a colleague mistaking a synthetic record for a real person mid-demo.

The review before anyone exports a row

Here's where teams get into trouble: they assume anonymisation is a switch. It isn't. Removing names and postcodes from a table of transactions is not anonymisation — it's pseudonymisation, and pseudonymised data is still personal data under UK GDPR. Small populations make it worse: a record with an unusual job title, a rare condition and a specific town can identify one person even with every direct identifier stripped.

The ICO has been consistent on this for years. Anonymisation is a result, not a technique, and you should be able to demonstrate it. If you cannot, treat the data as personal and apply the full weight of the law to it.

So run a short, documented review before any export leaves a production environment:

One page, one approver, a ticket number. Five minutes of paperwork that turns a six-week investigation into a five-minute answer.

The payoff is better tests, not just less risk

Teams that make this switch usually find the second-order benefit is the bigger one. Synthetic data that covers the edge cases catches the bugs that production copies never did — because a random sample of a million real customers contains almost none of the weird shapes that actually break a checkout. You get faster onboarding, environments that can be rebuilt from nothing, screenshots in slide decks that don't need blurring, and no quiet anxiety every time an auditor asks where the data lives.

Borrowing the nation's records is easy on day one. It's the day nine hundred that costs you.

All Articles

Related Articles

The Red Handle Nobody Pulls: Making Feature Flag Kill Switches Inspection-Ready

The Red Handle Nobody Pulls: Making Feature Flag Kill Switches Inspection-Ready

The Boundary Moved, the Report Didn't: Modelling UK Places Over Time

The Boundary Moved, the Report Didn't: Modelling UK Places Over Time

A Small Sign Before the Skip: Retiring Code Without Losing Its Story

A Small Sign Before the Skip: Retiring Code Without Losing Its Story