Using Synthetic Data in Tests
Synthetic test records keep real personal information out of source files, test output, and review systems.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Keep the properties that matter
For a name parser, choose invented examples with spaces, accents, and different lengths when those features matter. A test can cover text boundaries without copying a real contact list. Code points and visible characters guide that choice.
Check that failures stay informative
Use fictional identifiers and assert the location of a failing field without recording unrelated fields. This is an application of diagnostic logging context and keeps the test usable across environments.[1]
Use synthetic fields that reproduce the format behavior
To test a parser on accented names and commas, use invented examples with those features. A database dump may bring unrelated sensitive fields into test artifacts. Make the fixture small enough that every included detail has a clear purpose. See minimal failing input.
Example row: ID T-17, label "Café, East", count zero
Exercises encoding, quoted comma and zero handling
No need for a real customer record
Preserve edge conditions while changing irrelevant identities
Replace record IDs consistently if relationships matter. Check that synthetic dates and values still trigger the relevant boundaries. Review generated logs for incidental sensitive output and avoid deriving test data from inaccessible production state.