Test Data Refresh Workflow
Refresh realistic but anonymised test data on a schedule so tests do not drift from production shape.
Objective
Keep test data realistic and anonymised without production drift.
Environment
- A data anonymisation tool
- Access to a production snapshot
- Test environment seeding
Steps
1. Take a sanitised snapshot
Export a production-shaped dataset with PII removed or pseudonymised.
Expected state: The snapshot resembles production without real personal data.
2. Seed the test environment
Load the snapshot into the test environment with deterministic ids.
Expected state: Tests run against realistic data.
3. Refresh on a schedule
Repeat the export and seeding periodically as the schema evolves.
Expected state: Test data does not drift from production.
4. Verify determinism
Confirm tests relying on the data remain stable across refreshes.
Expected state: Refreshes do not cause flaky tests.
Decision points
Subset or full copy?
- Anonymised subset
- Full copy
Use an anonymised subset to keep size and privacy manageable.
Static fixtures or refreshed snapshots?
- Refreshed periodically
- Static only
Refresh periodically; static fixtures drift from production shape.
Expected outcome
Test data stays close to production shape while remaining anonymised and deterministic.
Verification
Confirm the snapshot contains no real PII, tests stay stable after a refresh, and the schedule is set.
Cleanup
Archive the anonymisation evidence and purge superseded snapshots.
Overview
Keep test data realistic and anonymised without production drift.
This workflow is reusable across teams and environments; adapt the commands to your tooling while keeping the sequence and checkpoints intact.
Environment and prerequisites
- A data anonymisation tool
- Access to a production snapshot
- Test environment seeding
Procedure
1. Take a sanitised snapshot
Export a production-shaped dataset with PII removed or pseudonymised.
Expected state: The snapshot resembles production without real personal data.
2. Seed the test environment
Load the snapshot into the test environment with deterministic ids.
Expected state: Tests run against realistic data.
3. Refresh on a schedule
Repeat the export and seeding periodically as the schema evolves.
Expected state: Test data does not drift from production.
4. Verify determinism
Confirm tests relying on the data remain stable across refreshes.
Expected state: Refreshes do not cause flaky tests.
# anonymise then load a production-shaped snapshot
anonymise export.sql --out test.sql && psql -d test -f test.sql
Verification
Confirm the snapshot contains no real PII, tests stay stable after a refresh, and the schedule is set.
Decision points
Subset or full copy?
- Anonymised subset
- Full copy
Recommendation: Use an anonymised subset to keep size and privacy manageable.
Static fixtures or refreshed snapshots?
- Refreshed periodically
- Static only
Recommendation: Refresh periodically; static fixtures drift from production shape.
Common failures
- Real PII in test data is a compliance breach.
- Static fixtures drift from production.
- Non-deterministic data causes flaky tests.