Seeding Realistic Test Data for Third-Party API Simulators
Valid fields aren't enough; simulators need related records with realistic history.

Integration testing against stateful APIs requires a simulator seeded with valid, related records at realistic points in their lifecycle. Tests can then run ordered workflows without hitting production, including failures that behave differently depending on which operations came before them. Realistic seed data is not a collection of plausible values but a reproducible model of the API’s constraints, relationships, and history, kept aligned with live behavior through continuous verification.
Why plausible-looking seed data is not the same as realistic seed data
A developer has a running simulator, pre-seeded records, and passing integration tests. The same application then fails against the live API. The simulator’s state machine may be correct, but its records may never have been valid production data. Tests consequently exercised different paths from those the application encounters in production. A passing result established compatibility with the seeded world.
Developers usually start with a field-level generator such as Faker, which supplies names, emails, and UUIDs. Those values make records look real at first glance. They do not establish whether a ship date follows an order date, whether an identifier passes its checksum, or whether a referenced resource exists. Faker has no independent understanding of the API’s schema or field relationships, so those constraints require explicit code.
Format validity and checksum correctness as the first layer of realistic data
Field correctness begins with the validation logic that the live API enforces. A string can match a regular expression and still be invalid. National ID numbers and tax identifiers, for example, can have checksums that a string of digits fails even if it looks right. If either the API or the application’s downstream validator rejects that value, the test stops before reaching the workflow it was intended to exercise.
Real Fake Data addresses this distinction by generating national IDs and tax numbers that pass real checksum validation. It also builds addresses from actual cities, streets, and postal-code prefixes. These guarantees apply at the field level. Their value is that valid inputs can pass through validators as production data would, leaving the test free to exercise later behavior. Without valid inputs, a failure may point to a fault in the fixture.
The same principle applies when an API has no national ID or tax fields. JSON types are only the outer boundary. Stripe card numbers use Luhn, PayPal email addresses must be deliverable-shaped, and Kalshi contract IDs follow a defined pattern. Each constraint narrows the set of acceptable strings beyond what a generic generator can infer from the type alone. A seed definition therefore needs the domain rule as well as the field name and type.
Real Fake Data has an edge-case flag that returns boundary values, unusual-but-valid records, and deliberately invalid checksums. Those inputs allow tests to examine rejection and boundary handling without confusing them with successful workflow fixtures. Reproduction is equally important in continuous integration. Passing a seed returns the same record every time, so a failed test can replay the input that triggered it.
Referential integrity across related resources, and why seeding schemas independently breaks it
Valid fields do not make a valid resource graph. An order can have a well-formed customer_id that matches no seeded customer, just as a Slack message can refer to a missing channel. A GitHub pull request can contain a plausible head_sha without a corresponding commit. The defect appears only when an operation follows a reference.
That distinction explains why independent schema seeding breaks integration coverage. An endpoint that resolves an order’s customer or a pull request’s commits needs the target record. A missing target produces a 404 or an error. The test then exercises reference failure instead of the workflow it was meant to cover, even if its initial request retrieved a convincing-looking resource. A successful read of one record is not evidence that its relationships are usable.
Parent resources are seeded first, and child resources use references from the parent ID set that this creates. For users with orders, this means orders refer to users that already exist in the seeded collection. For orders with line items, the line items in turn refer to orders that have already been seeded. This two-step pattern turns relationship correctness into part of construction rather than a repair attempted after independent generation.
Real Fake Data’s POST /v1/compose endpoint illustrates the same structural approach through nested generation. A request describes users with their orders and orders with their line items, and the response supplies a valid, reproducible, cross-referenced tree. The structural guarantee is the important part. Whether the graph is built in stages or returned together, dependent records must resolve to the intended resources. That establishes a coherent world, but it does not yet establish a believable point in time.
How to write integration tests where order of operations matters with pre-seeded lifecycle states
A coherent resource graph can still represent an unrealistically narrow slice of production. If every record has just been created, the suite has no starting points for operations that come later. A Stripe charge that has been captured differs from one that has merely been created. A GitHub pull request that has been reviewed and approved has different fields and transition rules from one just opened. A PayPal payment that has been partially refunded allows different next actions from one that is settled.
These distinctions make lifecycle state part of the test precondition. Records seeded only with a created status cannot directly support tests that require an already captured or partially refunded resource. The missing precondition changes what the test can reach. A suite may exercise creation repeatedly while leaving refund behavior and other state-conditional business logic untouched. The limitation comes from its starting data, even when the simulator implements the later transitions correctly.
The practical approach is to seed records at each meaningful lifecycle stage. Tests can then start from realistic preconditions without first taking every resource through all the steps that came before. This is not simply a change to a status field. The seeded record must represent the fields, related resources, and transition rules appropriate to that point in the lifecycle. Otherwise, the status claims a condition that the rest of the seeded world does not support.
Stateful simulation gives those preconditions their behavioral significance. A stateless mock returns the same body regardless of what the test did before, while a stateful simulator changes its responses as operations change its records. Starting from an uncaptured charge, the simulator returns a captured state only after capture, and a refunded state only after refund. A pre-seeded captured record instead begins at that later point. Its initial state must match the sequence already completed so that later calls test the right next actions.
Edge cases that only appear when records have history, and how to seed for them deliberately
Testing the lifecycle gets harder when a record’s current status does not fully explain how it behaves. Partial failures, retries, and transitions that happen in an unexpected sequence leave histories that change how later operations behave. Field generation cannot create those histories by itself. A realistic fixture must have the sub-resources and transitions that show how it reached its current condition. Otherwise, the test begins with a label for an edge case rather than the data that makes the case behave differently.
A Stripe payment intent illustrates the distinction between status and sequence. It can be created, have a payment method attached, be confirmed, fail, and then be retried with a new idempotency key. The retry’s behavior depends on the preceding attempt, so a record marked as failed is not a substitute for the full scenario. The seed must represent the prior sequence that gives the second attempt its meaning.
A GitHub pull request presents a related problem through review history. A pull request can be opened and reviewed, then have its head commit force-pushed before it is reviewed again. Its diff and review state are entangled with that sequence. A fixture containing only the latest pull request fields cannot stand in for all of those relationships. The relevant history includes the commits and reviews that make the current review state intelligible.
A PayPal order that was partially captured and then partially refunded has remaining capturable and refundable amounts derived from its capture and refund history. The current status is not enough to explain them. The seed must include the related capture and refund records, with values and references consistent with the resulting state.
The practical technique is a small catalog of named, versioned scenario seeds. Each entry brings together the records for a specific history. A scenario named partial_refund_after_dispute, for example, seeds the dispute record, original charge, partial capture, and partial refund in the correct sequence with consistent cross-references. The name selects a complete test precondition whose usefulness comes from the relationships and history behind it.
Version control makes that catalog reproducible as it changes. A test must be able to select a scenario by name and replay the exact version that caused a continuous integration failure. Random variation works against that purpose. Real Fake Data’s edge-case mode can provide difficult field values, but the full scenario still needs the failed attempt, partial capture, or other related records that explain how it behaves. Deterministic scenario seeds allow those history-dependent failures to be investigated as repeatable integration defects.
What continuous API verification adds to seed data quality over time
Even a carefully constructed scenario can become inaccurate as the live API evolves. An optional field can become required, an enum value can be deprecated, or a resource can gain a required sub-resource. A checksum algorithm can also change. Each change can invalidate records that were acceptable when the seed definition was written. Correctness at authoring time is therefore only a starting condition.
This drift is particularly difficult to detect from simulator tests alone. The simulator can continue accepting and returning stale seed data while the application’s suite continues passing. Nothing in that closed loop has to match the live API. A reproducible test may faithfully reproduce an obsolete assumption, and a consistent resource graph may still omit a newly required relationship. Determinism and referential integrity remain necessary, but neither establishes that the model is current.
Running the simulator’s behavior against the live API before every release can expose a mismatch between seeded records and current expectations. The seed definitions then need to stay in sync with those findings. Verification discovers when previously careful construction no longer matches the system being simulated.
Published fidelity scores make that comparison visible over time. A score tracks the percentage of API behaviors the simulator correctly reproduces, with daily checks against live behavior providing a continuing signal. That evidence makes simulation accuracy observable. It is evidence of verification practice, while individual scenario definitions and unresolved discrepancies still require attention. Seed quality depends on both the comparison and the maintenance that follows it.
Application tests run the simulator’s seeded workflows, while continuous verification checks the simulator against the live API. The seed catalog defines which production conditions those tests can reach. Keeping that catalog aligned with verified behavior is what allows a passing integration test to remain meaningful as the third-party API changes.


