Test data

Test data is a set of made-up records used to try out software, an import or a template before real records go near it. Good test data looks like the real thing in shape and size, while the names, emails and numbers in it belong to nobody and cannot reach anybody.

Software is easiest to test with records that look like the ones it will meet, and hardest to test safely with the records themselves. Test data closes that gap: rows that have the shape of real data and none of its owners.

What makes test data useful

The fields should match what the real system holds: the same columns, the same kinds of value and roughly the same size. A form tested with five tidy rows has not been tested with five thousand messy ones.

The values should also include the awkward cases real data is full of. Names with accents and apostrophes, very long addresses, blank optional fields, dates near the edge of a range and numbers with leading zeros break more imports than any amount of clean, plausible looking text.

Making sure it reaches nobody

A fake email address that happens to be real sends a test message to a stranger. The safe choice is a domain that is reserved for the purpose: RFC 2606 sets aside example.com, example.net and example.org, so nothing sent there is delivered. Phone numbers have the same problem, and some national regulators publish ranges kept back for drama and fiction for exactly this reason.

Identifiers are the other trap. A sequence of real looking account numbers can collide with genuine ones; random identifiers with enough length, such as a UUID or a long random string, make a collision unlikely enough to ignore.

Keeping it apart from real data

Test data is useful only while it is obviously test data. Mark it, keep it in its own file or database, and never mix it into an export that leaves the team. The point is that losing it costs nothing, and that stays true only while nothing real has been added to it.

Random each time, or fixed

Random data finds problems nobody thought of, and fixed data makes a failure repeatable. Many teams keep one fixed sample for regression checks and generate fresh rows when they want to look for something new.

Frequently asked questions

Why not test with a copy of real data?

Because a copy of real data is still real data. It carries the same privacy duties as the original, it tends to end up in places a production database never would, such as a laptop or a bug report, and a test email sent from it reaches a real inbox.

Which email addresses are safe to use in tests?

Addresses at example.com, example.net and example.org. RFC 2606 reserves those domains for documentation and testing, so mail sent to them is never delivered to a person.

Does test data need to look realistic?

It needs the same shape as real data, which is not the same as being convincing. Long names, accents, empty cells and odd dates find more problems than tidy values that look right.