Quick revision
The short answer
I would propose a mix that removes the need for production copies. Synthetic data generators produce realistic data that follows production's distributions and constraints without containing any real person. Where real-shaped data is still needed, masking or tokenisation runs in a controlled, audited pipeline rather than ad hoc scripts. Most tests should use small, curated datasets per scenario that live in version control with the tests. Underneath all of it, a clear data classification decides what may leave production and who may access anything derived from it.
What to remember
In this answer, we saw why privacy reviewers object to anonymised production copies: re-identification is often possible, pseudonymised data is still personal data, and copies spread and drift. The alternatives are synthetic generators that follow production's aggregate distributions and constraints, masking or tokenisation in one controlled and audited pipeline for the cases that need real skew, and small curated datasets that live with the tests for most automated testing. A data classification with access controls ties them together and decides what may be exported and who may see derived data.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would propose a mix that removes the need for production copies. Synthetic data generators produce realistic data that follows production's distributions and constraints without containing any real person. Where real-shaped data is still needed, masking or tokenisation runs in a controlled, audited pipeline rather than ad hoc scripts. Most tests should use small, curated datasets per scenario that live in version control with the tests. Underneath all of it, a clear data classification decides what may leave production and who may access anything derived from it.
Why this question is asked
For years, 'copy production and anonymise it' was the default way to get realistic test data. Privacy reviewers object now because anonymisation is much harder than it looks: a dataset with names removed can often be re-identified by combining a postcode, a birth date and a few purchases. Under GDPR, data that can be re-identified is still personal data, with all the duties that brings. Interviewers ask this scenario because it combines engineering, risk and negotiation. In this answer, we will see why the reviewers are right, then go through the three main alternatives with what each costs, how classification and access control tie them together, and how I would phase the change.
1Why Anonymised Copies Are a Problem
Anonymisation means changing data so that no person can be identified from it, by any means reasonably likely to be used. Removing names and emails is not enough. Quasi-identifiers, fields that are harmless alone but identifying together, remain: date of birth, postcode, gender, rare purchases, timestamps of logins. Linking a few of them with another dataset often points to one person. Data that has only been pseudonymised, with direct identifiers replaced by consistent tokens, is explicitly still personal data under GDPR.
There are also practical problems. Copies spread: a staging copy is copied to a developer laptop, a performance environment, a vendor's sandbox. Anonymisation scripts are often written once and not updated when new columns appear, so a new free-text notes field with customer comments slips through. And production copies are large, which makes environments slow to refresh and tests depend on whatever records happened to exist.
2Alternative 1: Synthetic Data Generators
Synthetic data is generated by code and never belonged to a real person. A good generator does more than fill fields with random strings. It follows the constraints of the schema and the business: valid references between tables, realistic order sizes, the right mix of countries and currencies, customers with zero, one or two hundred orders. The distributions come from aggregated statistics about production, such as 'orders per customer follow a long tail, 70 percent of payments are cards', which can be shared without sharing any individual record.
The big advantage is that synthetic data can include edge cases that production samples rarely contain on demand: names with apostrophes and non-Latin scripts, customers on leap days, orders at exactly the credit limit. The cost is building and maintaining the generators, which is real engineering work and must keep pace with the schema. Libraries such as Datafaker help with realistic values, but the domain rules are ours to write.
3Alternative 2: Masking or Tokenisation in a Controlled Pipeline
Some needs really do depend on production's shape, for example performance tests that must reflect real data volumes and skew, or analytics checks that need real value distributions. For those, masking replaces sensitive values with realistic fake ones, and tokenisation replaces them with tokens that can only be mapped back through a separate, protected service. Both can preserve formats and relationships, so the same customer gets the same token in every table.
The difference from today is control. The transformation runs in one pipeline owned by a named team, inside the production security boundary. It applies rules from the data classification, fails closed when it meets a column that has no rule, so a new column blocks the export instead of leaking, and writes an audit record of what was exported, when and to where. Privacy reviewers can then review one pipeline and its rules rather than dozens of scripts. Even so, the output should be treated as derived from production data, with access limited accordingly.
4Alternative 3: Small Curated Datasets per Scenario
For most automated tests, neither large synthetic data nor masked copies are the right tool. A test of 'a premium customer gets free shipping' needs one premium customer and one order, created by the test itself or loaded from a small dataset that lives next to the test in version control. These datasets are reviewed like code, change together with the tests, and contain no personal data because people wrote them.
This is also where the test quality improves most. Tests that relied on 'customer 48213 in staging happens to have an expired card' break whenever the copy is refreshed. Tests that create their own expired-card customer state their assumptions openly and run anywhere, including on a laptop and in parallel.
| Option | Good for | Main cost | Privacy risk |
|---|---|---|---|
| Synthetic generators | Staging, demos, volume tests | Building and maintaining generators | None if no real records used |
| Masking or tokenisation pipeline | Performance tests needing real skew | Pipeline, rules, audits | Reduced, still derived data |
| Curated datasets per scenario | Automated functional tests | Writing scenarios with the tests | None |
| Raw anonymised copies (today) | Nothing that the others cannot cover | Refresh time, sprawl | High: re-identification |
5Classification and Access Control Underneath
All three options rest on knowing what the data is. A data classification labels each table and column, for example public, internal, confidential, and personal or special-category personal data. The labels decide what the masking pipeline must transform, what may never leave production at all, and who may access an environment. Anything derived from production, even masked, gets its own classification and access list, so that a masked dataset is not treated like synthetic data.
I would phase the change rather than forbid copies overnight. First, classify the data and stop new ad hoc copies. Then build the masking pipeline for the few cases that need it, and synthetic generators for the main domain entities. Then move automated tests to curated datasets team by team, starting with the tests that read the most sensitive data. The privacy reviewers should be part of the design from the start, because their approval of the pipeline rules is what makes the remaining exports acceptable.
6Follow-up questions
Is differential privacy a practical option here?
For aggregated statistics, yes: adding calibrated noise to counts and distributions lets us describe production for the generators with a formal privacy guarantee. For record-level test data, it is rarely practical, because tests need individual, consistent records. I would mention it as a way to produce the statistics that drive the synthetic generators.
What about AI models that generate synthetic data from production?
They can produce realistic data, but a model trained on production records can memorise and reproduce real records, especially rare ones. If we use one, the training must happen inside the production boundary, and the output must be checked for close matches to real records before it leaves. For most teams, rule-based generators driven by aggregate statistics are simpler to approve.
How do you convince teams that their tests need rewriting?
By showing them that tests tied to specific production records are already fragile: they break on every refresh and cannot run in parallel or locally. Rewriting them to create their own data fixes those problems as well as the privacy one, and the shared builders and generators make it cheaper than they expect.
7Conclusion
In this answer, we saw why privacy reviewers object to anonymised production copies: re-identification is often possible, pseudonymised data is still personal data, and copies spread and drift. The alternatives are synthetic generators that follow production's aggregate distributions and constraints, masking or tokenisation in one controlled and audited pipeline for the cases that need real skew, and small curated datasets that live with the tests for most automated testing. A data classification with access controls ties them together and decides what may be exported and who may see derived data.
Open with
I'd start by agreeing with the reviewers on the problem: removing names is not anonymisation, because quasi-identifiers like birth date, postcode and purchase history can re-identify people, and pseudonymised data is still personal data under GDPR.
Then, if they want more
Copies also spread to laptops and vendor sandboxes. So I'd propose three alternatives used together. For most automated tests, small curated datasets per scenario, created by the tests or stored next to them in version control.
They contain no real people, and they make tests more reliable, because tests stop depending on whatever record happened to be in the last copy.
For staging, demos and volume testing, synthetic data generators that follow production's aggregate statistics, like the country mix or the long tail of orders per customer, and respect all the schema constraints, with deliberate edge cases such as unusual names or orders at the credit limit.
For the few needs that truly depend on production's shape, like a performance test, masking or tokenisation in one controlled pipeline inside the production boundary, owned by a team, failing closed on any unclassified column, and audited. Underneath, a data classification for every table and column decides what can leave and who can access derived data.
I'd phase it: stop new ad hoc copies first, then build the pipeline and generators, then move tests team by team.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- JUnit user guide, Mockito documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Teams copy anonymised production data into test environments, but privacy reviewers now...": https://scrivio-interview-library.netlify.app/java/integration-testing/88e286aab8/