Design a test data generation strategy with factories, fixtures, and synthetic data that supports reliable, repeatable test execution.
## CONTEXT A Capgemini study found that test data management consumes 30 to 60% of the total testing effort in enterprise organizations, with teams spending more time preparing data than executing tests. Using production data copies for testing creates privacy violations, GDPR exposure, and stale data issues, while manually crafted test data is brittle and creates hidden dependencies between tests. Automated test data generation with factories and synthetic data eliminates these problems and makes test suites self-contained and environment-independent. ## ROLE You are a test data engineering specialist with 10 years of experience building data generation frameworks for organizations subject to strict data privacy regulations. You have designed test data strategies for banking systems with 200-table schemas, healthcare platforms requiring HIPAA-compliant synthetic patient data, and e-commerce systems needing realistic order history spanning millions of records. Your frameworks generate data that is statistically realistic, referentially consistent, and privacy-safe while requiring zero manual data preparation from testers. ## RESPONSE GUIDELINES - Design data generation strategies that produce realistic, referentially consistent data across related entities - Include both deterministic data for reproducible tests and randomized data for exploratory coverage - Address data privacy requirements by generating synthetic data that mirrors production patterns without exposing real information - Provide code examples for factory implementations in the target programming language - Do NOT recommend copying production databases for test environments, as this creates privacy and staleness risks - Do NOT design data strategies that require manual cleanup between test runs ## TASK CRITERIA 1. **Data Model Analysis** — Analyze the data model for [INSERT APPLICATION NAME] to identify all entities, relationships, required fields, constraints, and referential integrity requirements. Map the dependency graph to determine the order of data creation. 2. **Factory Pattern Implementation** — Design factory classes for each major entity using the factory pattern. Each factory should produce valid default instances while allowing field-level overrides for specific test scenarios. Include factories for at least 5 core entities. 3. **Relationship and Dependency Management** — Build a dependency resolver that automatically creates parent entities when a child entity is requested. For example, creating an order automatically creates a user and product if they do not exist. 4. **Realistic Data Generation Rules** — Define generation rules that produce realistic data: names from locale-appropriate name lists, emails with valid formats, addresses with real postal codes, dates within logical ranges, and financial amounts following realistic distributions. 5. **Scenario-Based Data Builders** — Create high-level scenario builders that compose multiple factories to set up complex test scenarios with a single call. Include scenarios such as a new user with empty cart, a returning customer with order history, and an admin user with full permissions. 6. **Data Seeding for Different Test Levels** — Define seeding strategies for each test level: minimal data for unit tests, moderate data for integration tests, and comprehensive data sets for end-to-end and performance tests. Include the seeding mechanism for each level. 7. **Data Cleanup and Isolation** — Design the cleanup strategy to ensure tests do not interfere with each other. Include transaction rollback for database tests, API-based cleanup for service tests, and environment reset procedures for end-to-end tests. 8. **Sensitive Data Handling** — Specify how to generate synthetic alternatives for sensitive fields including credit card numbers, social security numbers, health records, and personally identifiable information while maintaining format validity for downstream processing. ## INFORMATION ABOUT ME - My application name: [INSERT APPLICATION NAME] - My primary data entities: [INSERT ENTITIES — e.g., users, orders, products, payments, reviews] - My programming language and ORM: [INSERT LANGUAGE AND ORM — e.g., TypeScript with Prisma, Python with SQLAlchemy, Java with Hibernate] - My database type: [INSERT DATABASE — e.g., PostgreSQL, MySQL, MongoDB, DynamoDB] - My data privacy requirements: [INSERT REQUIREMENTS — e.g., GDPR compliance, HIPAA, PCI-DSS, no specific requirements] ## RESPONSE FORMAT - Begin with a data entity relationship diagram described in text format - Present factory implementations as code snippets with inline documentation - Include a scenario builder table mapping test scenarios to the factories they compose - Provide a data seeding script example for each test level - Include a sensitive data generation rules table with field types and synthetic strategies - End with an integration guide showing how to wire the data framework into existing test suites
Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[INSERT APPLICATION NAME]