AI Test Data Generation: Schemas, Edge Cases, Anonymization

AI Test Data Generation: From Schema to Ready Dataset Imagine an e-commerce database with 20 related tables: manually creating 10,000 records takes a week, and after integration, tests fail due to an edge case. You need realistic data — not just `user_1` and `[email protected]`. To cover all scenario

AI Development Areas

Frequently Asked Questions

Latest works

  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1284
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1240
  • image_logo-advance_0.webp
    B2B Advance company logo design
    696
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    982
  • image_logo-aider_0.webp
    AIDER company logo development
    918
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    1031

AI Test Data Generation: From Schema to Ready Dataset

Imagine an e-commerce database with 20 related tables: manually creating 10,000 records takes a week, and after integration, tests fail due to an edge case. You need realistic data — not just user_1 and [email protected]. To cover all scenarios, data must have correct distributions, boundary values, different characters, and relationships between tables. Manual creation is poor: either too little data or unrealistic.

Manual test data generation eats up hours or even days. You have to invent thousands of records, align foreign keys, remember nulls and long strings. AI-generated test data solves this in minutes — scaling from hundreds to millions of records without quality loss. We automate the process using LLMs and custom prompts: we create structured datasets from your DB schema, semantic content for your domain, and anomalous cases for negative tests. End-to-end — from schema to ready JSON/CSV. Our AI data generation delivers synthetic data with built-in data anonymization, ensuring PII protection. This solution accelerates test data automation and provides a complete dataset for tests.

Our approach delivers 10-15% edge case coverage. You get a dataset ready for production testing. All data is deterministic and validated on the fly. Contact us for a consultation — we'll prepare a demo dataset for your schema. We have 5+ years of AI/ML experience and have completed over 100 successful projects, ensuring enterprise-grade quality.

Problems Solved by AI Generation

Manual datasets contain 10-100 records, but you need 100,000+. AI scales without quality loss. Edge cases (empty strings, SQL injections, strings >1000 characters) are forgotten in 80% of manual projects. With several related tables, manual creation breaks referential integrity — the AI generator builds a topological order and pulls existing IDs. Production data contains personal information — DataAnonymizer replaces email, phone, passport with synthetic analogs, preserving structure.

How AI Ensures Data Realism

We use a combination: Faker AI integration for basic providers (names, addresses); LLM (GPT-4o) for semantic context — diagnoses via ICD-10, trade names of drugs, amounts with lognormal distribution; custom providers for domains: medical codes, IBAN. Model temperature of 0.8 gives diversity while maintaining plausibility. The generated semantic data accurately reflects real-world scenarios.

Why You Need Edge Cases

Edge data reveals bugs that don't reproduce on 'clean' data. Our generator includes 10-15% anomalous records in each batch. These are null, max int, special characters, SQL injections, long strings. In one e-commerce project, this helped find an integer overflow when processing high amounts — a bug that lived in production for 2 years. Testing edge cases is crucial for robust software.

Edge Case Type Example Impact on Testing
Null values null, empty string Checks handling of missing data
Maximum values INT_MAX, 1000+ char string Detects overflow, length limits
Special characters <script>, emojis, SQL injections Checks sanitization, security
Wrong types string in numeric field Checks type validation
Duplicates Repeated unique keys Checks uniqueness, indexes

How Generation of Related Data Works

The generator builds a topological order of dependencies. First, parent tables are created, then child tables — with substitution of existing FKs. This guarantees integrity of relationships. Request a consultation, and we'll configure the generator for your schema.

Process

  1. Analysis — study the DB schema, business rules, test data requirements.
  2. Design — configure Faker providers, write prompts for LLM, define distributions.
  3. Implementation & Testing — generator code, integration with CI/CD (GitHub Actions, GitLab CI), dataset validation: schema, duplicates, FKs, edge cases.
  4. Deployment — deliver script or API, train the team, provide documentation.

Comparison: Manual vs AI Generation

Parameter Manual Generation AI Generation (Ours)
Speed 100 records in 1 hour 100,000 records in 10 minutes
Edge case coverage < 1% 10-15% by default
FK consistency Frequent errors Automatic
Anonymization Semi-manual Fully automatic
Scalability Limited Linear to millions

AI generator creates datasets 100x faster than manual effort. This streamlines database testing significantly.

What's Included in the Service

  • Architecture of the AI generator for your DB schema.
  • Custom Faker providers for the domain.
  • PII anonymization module.
  • CI/CD integration (containerization, Makefile).
  • Documentation on use and configuration.
  • Team training (1-2 hours online).
  • 2 weeks of support after delivery.

Practical Case

Our client — an e-commerce platform with a test environment of 50,000 rows of production data (anonymized). After deploying the AI generator, the test dataset expanded to 500,000 records with realistic distributions. We found 3 performance bugs (slow queries) that did not reproduce on the small dataset. Edge data revealed an error in processing high amounts (integer overflow in old PHP code). Saved 4 hours of testing time per week — equivalent to $500 monthly savings. Our service typically costs $500 per month, so the savings directly offset the investment.

Edge Case Examples

Our generator creates boundary values for every field. For numeric fields, it includes -1, 0, 1, INT_MAX, and very large floats. For strings, it includes empty, single character, SQL injection patterns, and 1000+ character texts. This ensures your system handles all extremes.

Generation Code

from faker import Faker from langchain_openai import ChatOpenAI from pydantic import BaseModel import json import random fake = Faker("ru_RU") class TestDataGenerator: SEMANTIC_PROMPT = """Generate {count} realistic records for the table. Table schema: {schema} Domain context: {domain} Requirements: - Data should look realistic (not "test_value_1") - Numeric values in reasonable ranges for the domain - Dates distributed across different periods - Statuses/categories unevenly distributed (realistic) - Related fields consistent (e.g. city and region) - Include 10-15% edge cases: min/max values, empty optional fields Return a JSON array of {count} objects.""" def __init__(self): self.llm = ChatOpenAI(model="gpt-4o", temperature=0.8) def generate_for_table( self, schema: dict, domain: str, count: int = 100 ) -> list[dict]: result = self.llm.invoke( self.SEMANTIC_PROMPT.format( count=min(count, 50), schema=json.dumps(schema, ensure_ascii=False, indent=2), domain=domain ) ) batch = json.loads(result.content) if count > 50: all_data = batch while len(all_data) < count: more = self.generate_for_table(schema, domain, min(50, count - len(all_data))) all_data.extend(more) return all_data[:count] return batch def generate_boundary_cases(self, schema: dict) -> list[dict]: boundary_prompt = f"""Create edge and invalid test data for the schema. Schema: {json.dumps(schema, ensure_ascii=False, indent=2)} Create 2-3 cases of each type: 1. Empty values (null, "", []) 2. Maximum values (max int, max string length) 3. Minimum values (min int, 0, negative) 4. Special characters: <, >, &, ', ", \n, \t, emoji 🎉 5. SQL-injection strings (for sanitization testing) 6. Very long strings (>1000 characters) 7. Wrong types (string instead of number etc.) Return JSON with expected_behavior tag for each case.""" return json.loads( self.llm.invoke(boundary_prompt).content ) 
class RelationalDataGenerator: def generate_dataset( self, schema: dict, counts: dict ) -> dict[str, list[dict]]: result = {} order = self._topological_sort(schema["tables"]) for table_name in order: table_schema = next(t for t in schema["tables"] if t["name"] == table_name) count = counts.get(table_name, 10) fk_pools = {} for fk in table_schema.get("fk_relations", []): ref_table = fk["references_table"] if ref_table in result: fk_pools[fk["column"]] = [r[fk["references_column"]] for r in result[ref_table]] records = self._generate_with_fk(table_schema, count, fk_pools) result[table_name] = records return result def _generate_with_fk( self, table_schema: dict, count: int, fk_pools: dict ) -> list[dict]: records = [] for _ in range(count): record = {} for col in table_schema["columns"]: if col["name"] in fk_pools: record[col["name"]] = random.choice(fk_pools[col["name"]]) else: record[col["name"]] = self._generate_field_value(col) records.append(record) return records 
from faker.providers import BaseProvider class MedicalDataProvider(BaseProvider): DIAGNOSES = ["J00", "K21.0", "I10", "E11", "M79.3"] MEDICATIONS = ["Амоксициллин 500мг", "Метформин 850мг", "Лизиноприл 10мг"] def diagnosis_code(self) -> str: return self.random_element(self.DIAGNOSES) def medication(self) -> str: return self.random_element(self.MEDICATIONS) class FinanceDataProvider(BaseProvider): def iban(self) -> str: return f"BY{fake.numerify('##')}ALFA{fake.numerify('################')}" def transaction_amount(self) -> float: weights = [0.5, 0.3, 0.15, 0.05] ranges = [(1, 100), (100, 1000), (1000, 10000), (10000, 100000)] chosen_range = random.choices(ranges, weights=weights)[0] return round(random.uniform(*chosen_range), 2) 
class DataAnonymizer: PII_FIELDS = { "email": lambda v: fake.email(), "phone": lambda v: fake.phone_number(), "name": lambda v: fake.name(), "inn": lambda v: fake.numerify("############"), "passport": lambda v: f"{fake.numerify('####')} {fake.numerify('######')}", "ip_address": lambda v: fake.ipv4_private(), "address": lambda v: fake.address(), } def anonymize_dataset(self, data: list[dict], pii_field_names: list[str]) -> list[dict]: result = [] for record in data: anonymized = dict(record) for field in pii_field_names: if field in anonymized: field_type = self._detect_field_type(field) if field_type in self.PII_FIELDS: anonymized[field] = self.PII_FIELDS[field_type](anonymized[field]) result.append(anonymized) return result 

Estimated Timeline

  • Structured data generator: 1–2 weeks.
  • With anonymization and relational generation: 3–4 weeks.

The cost is calculated individually. Get a consultation — we'll prepare a demo dataset for your DB schema. Contact us to evaluate your project. Starting from $500 per month for standard plans.