Three Ways to Create Test Data: How Do Random Generation, Masking and De-identification Differ?

· DataMint · 7 min read

Look into how to create test data and the terminology is confusing from the start. Masking, de-identification, pseudonymization, synthetic data, dummy data. It is worse because every vendor uses different names.

The methods used in practice fall into three broad groups. Make it up from scratch, bring production data over and blank out parts of it, or bring production data over and change it to different values. No single one is the right answer. The method that fits depends on the kind of test. Let's start with what happens to the same single customer under each method.

Same customer, three results

What one customer in the production DB becomes under each method (made-up sample values)
ItemProductionRandom generationMaskingTransformation
Name홍길동테스트001홍*동김서윤
RRN900101-1234568111111-1111111900101-*******900101-1947305
Mobile010-1234-5678010-0000-0001010-****-5678010-8271-4406
Sign-up date2003-04-172026-01-012003-04-172003-04-17
Accounts held3133

RRN here is the resident registration number, Korea's national ID number.

1. Random generation: make it up from scratch

Values are created and loaded with a script or tool, without looking at production data at all. There is no personal data from the start, so it is the safest. There is nothing to get approved and nothing to worry about deleting later.

The weakness is that it does not resemble reality. For a feature with three or four tables that is no problem. But to make up data that is consistent from customer to account, account to transaction, and transaction to settlement, you have to reimplement all the business rules in the generation script. Even then, the odd data that exists only in production does not appear. You cannot deliberately make up data nobody has imagined.

  • Good fit: new systems with no production data yet, unit tests, tests that deliberately insert boundary values
  • Poor fit: integration tests, reproducing production incidents, performance tests, data migration validation

2. Masking: bring it over and blank out parts

Production data is copied, and then the personal data is covered with asterisks or fixed characters. It is easy to implement. A few lines of UPDATE statements are enough. The structure, row counts and non-personal values remain identical to production.

The problem is the covered parts.

  • 900101-******* is not in RRN format, so it does not pass input validation. This customer cannot be edited and saved on screen.
  • Everyone born on the same day gets the same value. Logic that joins on this column or checks for duplicates gives wrong results.
  • If too little is blanked, the original can be guessed. With 홍*동, 010-****-5678 and the date of birth together, someone who knows the person knows who it is.

There is also a problem of order. Because this approach blanks after copying, production data sits on the development server as is until the blanking is done. If the script fails partway, it stays in that state.

  • Good fit: hiding values when displaying them on screen, statistics and analytics environments that only query
  • Poor fit: functional tests that enter, edit or validate the hidden values, business logic that joins on those values

3. Transformation: bring it over and change it to different values

As production data is brought over, personal data is changed to different values in the same format. 홍길동 becomes 김서윤, and an RRN becomes a different valid RRN. The same original changes to the same value in every table, so joins are kept.

Of the three methods, it is the most usable for testing. In exchange, it is the hardest to build properly. Each kind of number has its own validation rule, values have to match across tables, and it must not be possible to trace the original back from the changed value. This is usually the point where a homemade script that ran well at first collapses as tables are added.

One more thing to know. Transformed data still comes from production data. Even with names and numbers changed, if a transaction history or medical record is very unusual, someone who knows the person may recognize them. So transformed data still needs access permissions and a retention period.

  • Good fit: integration tests, reproducing incidents, performance tests, interface tests between systems
  • Poor fit: new business with no production data yet

What to base the choice on

Comparison by method
CriterionRandom generationMaskingTransformation
Does personal data remain?NoneRemains if too little is blankedNo values, but context remains
Passes input validationDepends on how it is builtDoes not passPasses
Relationships between tablesMust be matched by handBroken or collapsed togetherKept
Resemblance to productionLowHighHigh
Effort to buildGrows with business complexitySmallLarge if built in-house
Approval to access production dataNot neededNeededNeeded

In practice, they are mixed. This is the split we recommend.

  • For unit tests that developers run on their own PCs, random generation is enough.
  • Fill integration test and performance test environments with transformed data.
  • Showing an agent only part of a number on a production screen is not test data. It belongs to on-screen masking. Treating the two as the same problem leads to choosing the wrong tool.

DataMint Core is the third method

DataMint Core changes the values read from the production DB while they are being moved and loads them into the test DB. There is no copy-then-blank step, so production values never land on the development server. RRNs and card numbers keep their format and check digits, and the same value changes to the same value across tables and DBs.

DataMint Core job creation screen with RRN, phone number and email transformation rules attached to columns
The screen where you decide which rule changes each column. Columns that are not to be changed are moved as they are. (The console is shown in Korean. The data on screen is demo data.)

You can also choose what not to change

Changing every column is not the goal. Sign-up dates, amounts and code values have to go over as they are for the distribution to match production. When a job is created, the product first suggests the columns to change and their rules based on column names and comments, and the person in charge reviews them and adds or removes.

Closing

If the only question when choosing a method is "which is the safest," the answer is always random generation. But testing cannot be done with that answer, so production data ends up coming in secretly. Change the question to "which method is realistic enough for this test while leaving no people in the data," and choosing becomes easier.

What goes wrong when production data is used as is is covered in why you should not test with production data.

  • #test data generation
  • #data masking
  • #de-identification
  • #development database
  • #test data
  • #format-preserving transformation

Reviewing how you handle test data?

Tell us how you do it today and what databases you run, and we will look at the options with you.

More posts