QA Data Factory
Purpose
Generate realistic, consistent, and reproducible test data for automated and manual testing. Supports fixtures (static JSON/YAML), factory patterns (dynamic generation with overrides), faker-based seeds (realistic random data), and builder patterns (fluent API for complex objects). Produces fixtures, factory classes, seed scripts, and data cleanup utilities.
Trigger Phrases
- "Generate test data for [entity type]"
- "Create fixtures for [Users/Products/Orders]"
- "Factory pattern for test data"
- "Faker-based seed data"
- "Test data builder for [complex object]"
- "Realistic test data with locale [en_US/de_DE]"
- "Seed script for test database"
- "Data cleanup utilities for tests"
Data Generation Approaches
| Approach |
Use Case |
Output |
| Fixtures |
Static, version-controlled data; predictable |
JSON, YAML, CSV files |
| Factory pattern |
Dynamic generation with overrides; per-test customization |
Factory classes (TypeScript/Python) |
| Faker-based seeds |
Realistic but random; locale-aware |
Seed scripts, inline generation |
| Builder pattern |
Complex nested objects; fluent API |
Builder classes |
See references/factory-patterns.md for implementation details.
TypeScript Tools
| Tool |
Purpose |
| @faker-js/faker |
Realistic random data (names, emails, addresses, dates) |
| fishery |
Factory pattern with sequences and traits |
| factory.ts |
TypeScript factories with associations |
| Test data builders |
Fluent API for complex objects |
Python Tools
| Tool |
Purpose |
| Faker |
Realistic random data; locale support |
| factory_boy |
Factory pattern with sequences, subfactories |
| pytest-factoryboy |
Pytest integration; fixtures from factories |
| model_bakery |
Django model factories; minimal boilerplate |
See references/faker-guide.md for usage patterns.
Data Types Supported
| Type |
Examples |
Locale-aware |
| Users |
name, email, username, password hash |
Yes (names, formats) |
| Products |
SKU, title, price, category |
Yes (currency, formats) |
| Orders |
order ID, items, totals, status |
Yes (dates, currency) |
| Addresses |
street, city, postal code, country |
Yes |
| Payment info |
card numbers (test), expiry, CVV |
Test card patterns |
| Dates |
birthdate, created_at, expiry |
Yes (formats) |
| Emails |
valid format, domain |
Yes |
| Names |
first, last, full |
Yes (locale-specific) |
Output Artifacts
- Test data fixtures — Static JSON/YAML/CSV for predictable scenarios
- Factory classes — TypeScript or Python factories with overrides
- Seed scripts — Scripts to populate test DB with faker data
- Data cleanup utilities — Teardown scripts, truncate/reset helpers
Workflow
- Identify data needs — Entity types, required fields, relationships
- Choose approach — Fixtures vs factory vs faker based on use case
- Select tools — Match project stack (TS/Python, framework)
- Generate artifacts — Fixtures, factories, seed scripts
- Add cleanup — Teardown for isolation between test runs
Scope
Can do (autonomous):
- Generate fixtures, factories, seed scripts for specified entities
- Use Faker/faker-js for realistic locale-aware data
- Produce TypeScript (fishery, factory.ts) and Python (factory_boy, Faker) code
- Create data cleanup utilities
- Reference factory-patterns and faker-guide
Cannot do (requires confirmation):
- Add new dependencies without approval
- Modify production schemas or migrations
- Generate data for proprietary/restricted formats
Will not do (out of scope):
- Execute seed scripts or modify databases directly
- Generate production data or PII
- Bypass data validation or security constraints
References
| Topic |
File |
| Factory pattern implementations (TS, Python) |
references/factory-patterns.md |
| Faker library usage for realistic data |
references/faker-guide.md |
Quality Checklist
Troubleshooting
| Symptom |
Likely Cause |
Fix |
| Data conflicts between tests |
Shared state; no cleanup |
Add teardown; use unique IDs/emails per test |
| Unrealistic data |
Default faker; wrong locale |
Set locale; use appropriate faker providers |
| Factory too verbose |
Over-specification |
Use sensible defaults; override only when needed |
| Seed non-reproducible |
Random seed not set |
Use faker.seed(123) or equivalent |
| Schema mismatch |
Generated fields don't match API/DB |
Align with OpenAPI/DB schema; validate output |
1---2name: qa-data-factory3description: Generate realistic test data using fixtures, factory patterns, and faker-based seeds for consistent and reproducible test environments.4---56# QA Data Factory78## Purpose910Generate realistic, consistent, and reproducible test data for automated and manual testing. Supports fixtures (static JSON/YAML), factory patterns (dynamic generation with overrides), faker-based seeds (realistic random data), and builder patterns (fluent API for complex objects). Produces fixtures, factory classes, seed scripts, and data cleanup utilities.1112## Trigger Phrases1314- "Generate test data for [entity type]"15- "Create fixtures for [Users/Products/Orders]"16- "Factory pattern for test data"17- "Faker-based seed data"18- "Test data builder for [complex object]"19- "Realistic test data with locale [en_US/de_DE]"20- "Seed script for test database"21- "Data cleanup utilities for tests"2223## Data Generation Approaches2425| Approach | Use Case | Output |26|----------|----------|--------|27| **Fixtures** | Static, version-controlled data; predictable | JSON, YAML, CSV files |28| **Factory pattern** | Dynamic generation with overrides; per-test customization | Factory classes (TypeScript/Python) |29| **Faker-based seeds** | Realistic but random; locale-aware | Seed scripts, inline generation |30| **Builder pattern** | Complex nested objects; fluent API | Builder classes |3132See `references/factory-patterns.md` for implementation details.3334## TypeScript Tools3536| Tool | Purpose |37|------|---------|38| **@faker-js/faker** | Realistic random data (names, emails, addresses, dates) |39| **fishery** | Factory pattern with sequences and traits |40| **factory.ts** | TypeScript factories with associations |41| **Test data builders** | Fluent API for complex objects |4243## Python Tools4445| Tool | Purpose |46|------|---------|47| **Faker** | Realistic random data; locale support |48| **factory_boy** | Factory pattern with sequences, subfactories |49| **pytest-factoryboy** | Pytest integration; fixtures from factories |50| **model_bakery** | Django model factories; minimal boilerplate |5152See `references/faker-guide.md` for usage patterns.5354## Data Types Supported5556| Type | Examples | Locale-aware |57|------|----------|--------------|58| **Users** | name, email, username, password hash | Yes (names, formats) |59| **Products** | SKU, title, price, category | Yes (currency, formats) |60| **Orders** | order ID, items, totals, status | Yes (dates, currency) |61| **Addresses** | street, city, postal code, country | Yes |62| **Payment info** | card numbers (test), expiry, CVV | Test card patterns |63| **Dates** | birthdate, created_at, expiry | Yes (formats) |64| **Emails** | valid format, domain | Yes |65| **Names** | first, last, full | Yes (locale-specific) |6667## Output Artifacts68691. **Test data fixtures** — Static JSON/YAML/CSV for predictable scenarios702. **Factory classes** — TypeScript or Python factories with overrides713. **Seed scripts** — Scripts to populate test DB with faker data724. **Data cleanup utilities** — Teardown scripts, truncate/reset helpers7374## Workflow75761. **Identify data needs** — Entity types, required fields, relationships772. **Choose approach** — Fixtures vs factory vs faker based on use case783. **Select tools** — Match project stack (TS/Python, framework)794. **Generate artifacts** — Fixtures, factories, seed scripts805. **Add cleanup** — Teardown for isolation between test runs8182## Scope8384**Can do (autonomous):**85- Generate fixtures, factories, seed scripts for specified entities86- Use Faker/faker-js for realistic locale-aware data87- Produce TypeScript (fishery, factory.ts) and Python (factory_boy, Faker) code88- Create data cleanup utilities89- Reference factory-patterns and faker-guide9091**Cannot do (requires confirmation):**92- Add new dependencies without approval93- Modify production schemas or migrations94- Generate data for proprietary/restricted formats9596**Will not do (out of scope):**97- Execute seed scripts or modify databases directly98- Generate production data or PII99- Bypass data validation or security constraints100101## References102103| Topic | File |104|-------|------|105| Factory pattern implementations (TS, Python) | `references/factory-patterns.md` |106| Faker library usage for realistic data | `references/faker-guide.md` |107108## Quality Checklist109110- [ ] Generated data matches entity schema/contract111- [ ] Locale specified when names/addresses/formats matter112- [ ] No real PII or production-like secrets113- [ ] Fixtures are deterministic; faker seeds use configurable seed for reproducibility114- [ ] Cleanup utilities included for test isolation115- [ ] Factory overrides documented for common scenarios116117## Troubleshooting118119| Symptom | Likely Cause | Fix |120|---------|--------------|-----|121| Data conflicts between tests | Shared state; no cleanup | Add teardown; use unique IDs/emails per test |122| Unrealistic data | Default faker; wrong locale | Set locale; use appropriate faker providers |123| Factory too verbose | Over-specification | Use sensible defaults; override only when needed |124| Seed non-reproducible | Random seed not set | Use faker.seed(123) or equivalent |125| Schema mismatch | Generated fields don't match API/DB | Align with OpenAPI/DB schema; validate output |