Test Data
Test data is the data needed to execute tests: the values a test enters, and the records that must already exist before it starts — accounts, products, orders and settings, each in a known state. To test "a customer can cancel an order before it ships", clicking Cancel is the action, but the test cannot begin without a customer who can log in and an order that is paid and not yet shipped.
Each test case should name its test data; this lesson covers choosing it, sourcing it safely and managing it so tests can be repeated.
Why it matters
Data decides what a test can find. Tests run only with tidy records — "Test User", one order, a short address — prove the happy path and little else; defects wait in the empty field, the name with an apostrophe, the order delivered exactly 14 days ago. Data also decides whether a result can be trusted: a test that fails because a colleague changed a shared account, or passes because of a leftover record, wastes time and hides real problems.
Data carries legal risk too. A copy of production in a test environment exposes real customers’ personal data to everyone with test access, usually under weaker controls than production. In Saudi Arabia that is processing of personal data under the Personal Data Protection Law (PDPL).
Four kinds of test data
For each test condition, ask which data would show whether the behaviour is right. Four kinds cover most needs; a good test set mixes them on purpose, building on the lessons on positive and negative testing and on edge cases.
- Valid: data the system must accept and process — a registered customer, an in-stock product, an email such as
sara.k@example.com. - Invalid: data the system must refuse safely — an empty required field, a wrong format, an expired card, or a record in the wrong state, such as an order that is already cancelled.
- Boundary: values at the edges of what is allowed — the longest name, zero, the last day of a period. Boundary value analysis, in the test design module, chooses them precisely.
- Production-like: data that resembles real use in shape and volume — Arabic and Devanagari names, long addresses, a customer with hundreds of orders — without belonging to a real person.
Try it: Special Character Dataset Generator Try it: Unicode Dataset Generator
Where test data comes from
The first two sources below are synthetic: made-up data that describes no real person. Synthetic data is the default because you control every value, including boundaries, invalid values and rare states.
- Hand-made: a tester writes the few exact records a test needs in a spreadsheet, a fixture file or a seed script. Precise, but slow when you need volume.
- Generated: a tool or script creates records from rules, or the test creates them through the product’s API so they obey the business rules. Repeatable, from ten rows to a million.
- Masked production data: a production copy with names, ids, phone numbers, emails and addresses replaced, shuffled or removed, and the links between tables kept. Realistic — useful for a migration rehearsal, for example — but it needs an approved process.
- Production data as it is: real records. Not for test environments without a legal basis, approval and production-level protection.
Hand-madeSynthetic
A tester writes the exact records a test needs
- Control over values:
- Full: any state, boundary or invalid value
- Realism:
- Only the cases someone thought of
- Volume:
- A few records
- Personal data risk:
- None: describes no real personPass
- Best for:
- Exact states and boundaries in test cases
GeneratedSynthetic
A tool, a script or the product’s API creates records from rules
- Control over values:
- High: rules set formats, ranges and volume
- Realism:
- As realistic as its rules
- Volume:
- Ten rows to a million
- Personal data risk:
- None: describes no real personPass
- Best for:
- Repeatable set-up, load and localisation data
Masked production copyFrom production
Personal fields replaced, shuffled or removed; links between tables kept
- Control over values:
- Low: only what production happens to hold
- Realism:
- Real shapes and distributions
- Volume:
- A subset or full size
- Personal data risk:
- May still identify people: needs approvalCaution
- Best for:
- Migration rehearsals that need real distributions
Production copy as it isReal data
Real customers’ records, unchanged
- Control over values:
- Low: only what production happens to hold
- Realism:
- Real, including its mistakes
- Volume:
- Full size
- Personal data risk:
- Real personal data in a test systemFail
- Best for:
- Not for test environments
Treat masked data as personal data until your data protection officer or privacy team decides otherwise.
Try it: Test Data Factory Try it: Fake User Generator Try it: Fake Customer Generator
Personal data: keep real people out of test systems
The PDPL, overseen by the Saudi Data and AI Authority (SDAIA), defines personal data broadly: any data that can identify a person directly or indirectly, such as a name, an identity number, an address or a phone number. Health data is among the categories classed as sensitive.
Masking does not automatically make data anonymous. Replace the names but keep the birth date, district and employer, and a record can still point to one person. Whether a masked set is still personal data is for your data protection officer or privacy team to decide; until they do, treat it as personal data.
- Use domains reserved by RFC 2606, such as
example.com, for test emails, so no message reaches a real inbox. - Pay only with the payment provider’s published test cards in its sandbox.
- Keep real personal data out of bug reports, screenshots, logs and AI tools; if you find some in a test system, report it and do not copy it.
Try it: Fake Email Generator Try it: Saudi Address Test Data
Test data management
Test data management (TDM) is how a team plans, provides, protects and maintains test data so that tests stay repeatable. A large organisation may have a dedicated role for it; on a small team it is a few habits:
- Plan: write the data of each test case as a state. "A valid customer" is not test data; "customer C-101 with one card order delivered three days ago" is.
- Provide: create data with scripts or generators kept in version control next to the tests, not by hand on execution day.
- Isolate: give each tester or parallel run its own records with unique ids, so tests do not change each other’s data.
- Keep it current: write dates relative to the run ("delivered today minus 14 days"); a fixed date stops testing the rule weeks later.
- Reset and retire: restore a known baseline between runs, and delete exports and copies you no longer need.
Worked example: test data for a refund rule
Requirement: "Customers can request a refund within 14 days of delivery. Card payments are refunded to the card; cash-on-delivery orders to the customer’s wallet."
Before writing steps, the tester lists the data: valid rows for both refund routes, boundary rows on each side of day 14 with relative dates, invalid rows for a wrong state and a wrong owner, and one production-like row. One question goes to the product owner first: does "within 14 days" include day 14? The sheet assumes it does.
ID Kind Record (all synthetic) Expected
TD-01 valid card order, delivered today-3, 240.00 SAR refund to card
TD-02 valid cash-on-delivery order, delivered today-5 refund to wallet
TD-03 boundary card order, delivered today-14 refund accepted
TD-04 boundary card order, delivered today-15 refund refused
TD-05 invalid state order shipped, not yet delivered no refund option
TD-06 invalid state order already refunded refund refused
TD-07 invalid owner order of C-102, opened by its id access denied
TD-08 production-like customer with 350 orders, Arabic full name history pages load
Log in as C-101 for TD-01 to TD-07; TD-08 logs in as C-103.
All emails end in @example.com. Dates are relative to the run date.
Restore baseline "refunds-v3" before each run.Common mistakes
- Testing only with tidy, typical data, so empty, very long, non-Latin and wrong-state data are never tried.
- Copying production data, or "masking" it by changing only the names.
- Sharing one test account between testers or parallel runs, so tests change each other’s data and fail at random.
- Hard-coding dates that go stale: a test for "delivered on 3 March" stops testing the 14-day rule weeks later.
- Writing "a valid customer" instead of the exact record and its state, so nobody can reproduce the test or the bug.
The QA perspective
A working tester plans data during test analysis and design, not on execution day, and flags the states that are hard to create, such as an order delivered 15 days ago or a payment the bank declined. Raise them in refinement: some need a developer’s help, such as a seed script or a way to set the delivery date.
Record the data in the test case and in every bug report: the record id, its state and how it was created. ISO/IEC/IEEE 29119-3 treats test data requirements as a documentation item of their own; on an agile team, a short note in the story is usually enough.
Practice exercise
Prepare the test data for appointment booking
A clinic app has three rules: appointments are booked 1 to 30 days ahead; a patient can hold at most 2 upcoming appointments; patients under 18 are booked from a guardian’s account. Write a test data sheet of at least eight rows covering all four kinds of data, with the expected result and source of each row.
Then reply to a teammate who suggests copying last month’s patients from production and changing their names.
Show the model answer
Valid: an adult with no appointments books for today + 7; a guardian books for a linked 10-year-old (both booked).
Boundary: today + 1 and today + 30 (booked), today and today + 31 (refused); a second upcoming appointment (booked), a third (refused); a patient who turns 18 today books alone, one who turns 18 tomorrow is sent to a guardian. Ask the product owner whether age counts on the booking day or on the appointment day.
Invalid: a 17-year-old’s own account, a past or empty date, a guardian booking for an unlinked child (all refused). Production-like: 500 generated patients with Arabic, Devanagari and Latin names (search finds a patient by part of the name in each script).
Sources: hand-made records for exact states, generated ones for volume; all synthetic, with ages and dates computed from the run date.
Reply: "No. Patient records are personal data, and the PDPL classes health data as sensitive. Birth date, district and visit history can still identify a person, and synthetic data gives us the states and boundaries we need anyway."
Frequently asked questions
Can we ever use production data for testing?
Only under control: a legal basis and approval from whoever is responsible for data protection, masking that has been checked, the same access control as production, and deletion after use. Synthetic data is the default. Checks that must run in production use dedicated test accounts, not customers’ records.
Is masked data the same as anonymous data?
No. Masking replaces or hides selected fields; the remaining fields can still identify someone when combined, and some masking can be reversed. Data counts as anonymous only when it can no longer be linked to a person, and deciding that is a job for your privacy team.
Who is responsible for test data?
It is shared. Testers define the data requirements and check the data before a run; developers or DevOps engineers often write the seed scripts and reset jobs; the data protection officer decides on anything derived from personal data. Some large organisations have a dedicated test data management role.
Should test data be written in the test case or kept in a separate file?
Both, depending on size. Write the exact record or value in the test case when there are only a few; keep larger sets in a data table or file that the test case refers to, in version control, so the same steps can run with many rows. This is the basis of data-driven testing.
References
- ISTQB Certified Tester Foundation Level (CTFL) v4.0The foundation syllabus of software testing: test levels and types, test design techniques, test management and tools.
- Personal Data Protection Law (English translation)The Saudi law governing personal data — why test environments should use synthetic data rather than copies of real customer records.
- ISO/IEC/IEEE 29119-3:2021 — Software and systems engineering — Software testing — Part 3: Test documentationTemplates and content for test documentation — test policy, strategy, plan, status and completion reports, incident reports.
- RFC 2606: Reserved Top Level DNS NamesReserves example.com, example.net, example.org and .test/.example for documentation and testing — the domains to use in fake data.
Practise with Mutqan tools
One-stop factory for synthetic test data: users, customers, companies, addresses, numbers, dates and strings in JSON, CSV, SQL or XML.
Generate fake user records (name, username, email, password, avatar seed, role) for test accounts.
Generate test email addresses with safe reserved domains (example.com, test) and plus-addressing variants.
Generate SQL seed scripts (CREATE TABLE + INSERTs) with realistic test rows for any dialect.
Generate inputs full of special characters: quotes, SQL/HTML/JSON metacharacters, control chars, emoji and path tricks.
Generate Arabic names, addresses, sentences, numbers (Arabic-Indic digits) and RTL edge cases for localisation testing.
Go deeper
Your progress on this topic
Not started
Mark the topic complete when you have studied it and done the exercise.
Sign in to track your progress
Mark topics complete, continue where you left off and unlock specialisation exams.