Skip to content
AI Dev Toolkit.
Esc
  • Loading…

Prompt template · Data

Test data generation prompt

A good test data generation prompt gives the model your schema with its business rules, the number of records, what they are for and the edge cases you need. This template keeps records valid and internally consistent, uses clearly fake personal data such as example.com emails, and maps each edge case to the records that cover it.

Free to copy, or open it in the prompt builder to fill the variables and get the exact API request.

203 tokens unfilled · 326 with the example below · o200k_base (GPT-4o and later)

Template

The test data prompt template (copy it)

Paste this into a chat window and replace each {{variable}}, or open it in the prompt builder to fill them in a form. Sections are marked with XML tags, which every major model reads well.

Prompt (one message, plain text)
You generate realistic test data that exercises edge cases. You never produce real people’s personal data.

<context>
The schema and validation rules:
<schema>
{{schema}}
</schema>
</context>

<constraints>
- Every record must be valid against the schema and rules, unless it is listed as a deliberately invalid case.
- Include these edge cases: {{edge_cases}}.
- Vary values realistically: lengths, distributions, character sets (including non-ASCII names), dates across years and time zones.
- Personal data must be clearly fake: emails at example.com, phone numbers from reserved test ranges where they exist, no real people’s names combined with real addresses.
- Keep the data internally consistent (an order’s total equals its line items).
</constraints>

<output_format>
{{output_format}}, in one code block. After it, a list mapping each edge case to the record IDs that cover it.
</output_format>

<task>
Generate {{count}} records for {{purpose}}.
</task>
For an API call: system prompt and user message

With a system prompt, the role, constraints and output format stay fixed across calls (and can be cached), while the context and task go in the user message.

System prompt
You generate realistic test data that exercises edge cases. You never produce real people’s personal data.

<constraints>
- Every record must be valid against the schema and rules, unless it is listed as a deliberately invalid case.
- Include these edge cases: {{edge_cases}}.
- Vary values realistically: lengths, distributions, character sets (including non-ASCII names), dates across years and time zones.
- Personal data must be clearly fake: emails at example.com, phone numbers from reserved test ranges where they exist, no real people’s names combined with real addresses.
- Keep the data internally consistent (an order’s total equals its line items).
</constraints>

<output_format>
{{output_format}}, in one code block. After it, a list mapping each edge case to the record IDs that cover it.
</output_format>
User message
<context>
The schema and validation rules:
<schema>
{{schema}}
</schema>
</context>

<task>
Generate {{count}} records for {{purpose}}.
</task>

Variables

What do the variables mean?

{{schema}}
The table definition, TypeScript type, JSON Schema or Pydantic model, plus business rules such as “end_date after start_date”.
{{count}}
How many records, such as 25. Small sets with deliberate coverage beat large random ones for tests.
{{purpose}}
What the data is for, such as “unit tests of the invoice PDF renderer” or “a demo account”.
{{edge_cases}}
The cases you need covered, such as “empty optional fields, a 200-character name, a total of 0, a leap-day date”.
{{output_format}}
The format, such as JSON array, CSV with a header, or SQL INSERT statements.

Use

When should I use this test data prompt?

Use it to build fixtures for tests, seed data for a staging environment or a demo account that looks real. It is most useful when the data has rules (consistent totals, valid dates, realistic names across languages) that random generators ignore.

For large volumes or property-based testing, use a generator library such as Faker or Hypothesis; they are reproducible and free. This template is for small, deliberate sets where each record has a reason to exist.

Structure

Why is the prompt structured this way?

The schema plus rules is what makes generated data valid. Types alone produce records that parse but break business logic, such as end dates before start dates, so the rules are part of the same section.

Edge cases are a variable because they are the point of test data. Listing them explicitly, and asking for a map from case to record IDs, turns the output into coverage you can check rather than a pile of plausible rows.

The fake-personal-data rule is a privacy safeguard. Models can reproduce real names and addresses they have seen; example.com emails and obviously synthetic details keep fixtures safe to commit and share.

Example

Example: a filled-in test data prompt

{{schema}}
type Booking = {
  id: string;            // "bk_" + 6 digits
  guestName: string;     // 1-120 chars
  email: string;
  checkIn: string;       // YYYY-MM-DD
  checkOut: string;      // after checkIn
  guests: number;        // 1-8
  totalPence: number;    // nights * nightly rate, rate 4,500-30,000
};
{{count}}
12
{{purpose}}
unit tests of the booking confirmation email
{{edge_cases}}
a one-night stay, a stay across New Year, a 120-character guest name, a non-Latin guest name, 8 guests
{{output_format}}
A JSON array

What to look for. The consistency rule matters here: each totalPence must equal the number of nights times a rate in range, which is easy to check in a test and easy for a careless generator to get wrong. The coverage map should name at least one record per edge case.

The complete filled-in prompt (326 tokens)
Filled-in prompt
You generate realistic test data that exercises edge cases. You never produce real people’s personal data.

<context>
The schema and validation rules:
<schema>
type Booking = {
  id: string;            // "bk_" + 6 digits
  guestName: string;     // 1-120 chars
  email: string;
  checkIn: string;       // YYYY-MM-DD
  checkOut: string;      // after checkIn
  guests: number;        // 1-8
  totalPence: number;    // nights * nightly rate, rate 4,500-30,000
};
</schema>
</context>

<constraints>
- Every record must be valid against the schema and rules, unless it is listed as a deliberately invalid case.
- Include these edge cases: a one-night stay, a stay across New Year, a 120-character guest name, a non-Latin guest name, 8 guests.
- Vary values realistically: lengths, distributions, character sets (including non-ASCII names), dates across years and time zones.
- Personal data must be clearly fake: emails at example.com, phone numbers from reserved test ranges where they exist, no real people’s names combined with real addresses.
- Keep the data internally consistent (an order’s total equals its line items).
</constraints>

<output_format>
A JSON array, in one code block. After it, a list mapping each edge case to the record IDs that cover it.
</output_format>

<task>
Generate 12 records for unit tests of the booking confirmation email.
</task>

Models

Does it work the same in ChatGPT, Claude and Gemini?

Yes, the structure works in all three: tagged sections that keep your material apart from the instructions, and an explicit output format. The tips below cover where the providers’ own guides differ for this test data prompt.

  • OpenAI GPT

    Structured Outputs can enforce the record shape, but OpenAI’s supported schema features are a subset of JSON Schema; check that your patterns and limits are supported before relying on them.

  • Claude

    Anthropic’s structured outputs return a 400 error for numeric limits such as minimum, so keep ranges like “1–8 guests” in the prompt text and validate them in your test setup.

  • All models

    Commit the generated fixture, not the prompt output on each test run. Tests need data that doesn’t change between runs.

FAQ

Questions people ask

Can ChatGPT generate test data?

Yes, for small, deliberate sets where each record has a reason to exist: fixtures for a renderer, seed data for staging, a demo account. Ask for realistic variety, including non-ASCII names and dates across years, and check the consistency rules yourself. Commit the generated fixture, because tests need data that doesn’t change between runs.

When should I use Faker instead?

For large volumes or property-based tests. Generator libraries such as Faker and Hypothesis are reproducible, free and fast at any size. This template is for the cases they handle badly: data with rules that span fields, such as a total equal to nights times a nightly rate, and named edge cases you want covered on purpose.

How do I keep real personal data out of fixtures?

Ask for obviously fake values. The template requires emails at example.com, phone numbers from reserved test ranges where they exist, and no real names combined with real addresses, because models can reproduce details they have seen. Fixtures built that way are safe to commit to a repository and share.

Related

Edited the template? Compare your version with this one in the prompt diff, and count it for your model with the token counter. In the glossary: structured outputs. Browse all 29 prompt templates.

Keep exploring