test-data-strategies

Designs deterministic test data using fixtures, factories, and builders for isolated tests.

Updated Dec 29, 2025
One-click install
npx skills add https://github.com/snoodleboot-io/discrecontinual_equations --skill test-data-strategies-snoodleboot-io
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-data-strategies
Source: https://github.com/snoodleboot-io/discrecontinual_equations/tree/main/.claude/skills/test-data-strategies
Command: npx skills add https://github.com/snoodleboot-io/discrecontinual_equations --skill test-data-strategies-snoodleboot-io

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Test suites fail intermittently or pass for the wrong reasons when test data is shared, mutated, nondeterministic, or copied unsafely from production. This Skill provides concrete patterns for building test data that keeps tests isolated, deterministic, and readable. ## Core Features & Use Cases - Fixtures, Factories, and Builders: Guidance on choosing the right construction pattern, with examples in pytest, factory_boy, fishery, and FactoryBot. - Isolation and Determinism: Rules for fixture scoping, transaction rollback isolation, seeded generators, and monotonic sequences to eliminate order-dependent and flaky tests. - Production Data Hazards: Explains why pseudonymization fails, how subsetting breaks referential integrity, and a policy for synthetic-first test data. - Use Case: A team sees tests pass locally but fail under pytest-xdist sharding. Apply the shared-mutable-fixture rules to convert module-scoped mutable fixtures into function-scoped factories and eliminate the order dependency. ## Quick Start Review my pytest fixtures and factories and identify which ones create shared mutable state or nondeterministic data that could cause order-dependent test failures.

Frequently Asked Questions about test-data-strategies

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between fixtures, factories, and builders in tests?▼

Use fixtures for expensive immutable values shared read-only, factories as the default for domain objects needing fresh instances per test, and builders when objects have many fields or ordered construction steps. Prefer established libraries like factory_boy or fishery over hand-rolled factories.

How do I fix order-dependent tests caused by shared fixtures?▼

Order-dependent tests usually come from mutable fixtures with broad scope. Default to function scope, escalate scope only for immutable values like frozen dataclasses or MappingProxyType, and give external state like database rows explicit teardown via transaction rollback.

How do I make test data deterministic in pytest?▼

Seed random and Faker centrally in an autouse fixture with an overridable TEST_SEED environment variable. Also eliminate hidden nondeterminism from uuid4(), datetime.now() in factory defaults, set iteration order, and random default values.

Is it safe to use anonymized production data in tests?▼

Pseudonymized production data is not anonymized; quasi-identifiers like ZIP code, birth date, and sex allow re-identification by linkage. Prefer synthetic data by default, and require irreversible transformation, production-grade access controls, and expiry for any real data.

Why do random values for unique columns cause test failures?▼

Random values for unique columns collide far sooner than intuition suggests, producing intermittent uniqueness violations. Use a monotonic per-run sequence such as itertools.count to guarantee uniqueness deterministically.