← Concepts

阅读中文版本

Fixture Factory Pattern

Fixture Factory Pattern governs test data construction, shaping system behavior under specific failure modes and workloads.

testing

Definition

Fixture Factory Pattern is a design property concerning test data construction. It defines how the system behaves under specific conditions — what guarantees hold, what trade-offs apply, and how the mechanism interacts with related techniques. The property is only meaningful when its preconditions are met; outside those conditions it provides no benefit and may add cost.

Context and scope

Apply Fixture Factory Pattern when designing systems where test data construction matters. It is most useful under partial failure, high load, or correctness requirements. Pair it with observability to verify the claimed behavior in production. Do not assume the property holds without testing the specific configuration and workload.

Common misconceptions

  • Fixture Factory Pattern eliminates all problems in its domain — it only bounds or shapes specific failure modes, not all pathologies.
  • Fixture Factory Pattern is free once you adopt the right tool — the property depends on configuration, workload, and failure pattern, not the product label alone.

Anti-patterns

  • Enabling Fixture Factory Pattern without measuring its cost in latency, availability, or operational complexity under production-like conditions.
  • Assuming Fixture Factory Pattern composes safely with other guarantees — combining mechanisms can introduce new failure modes or negate benefits.

Related concepts

Authoritative source

https://martinfowler.com/articles/practicalTestPyramid.html

What it is

Fixture Factory Pattern is a design property concerning test data construction. It defines how the system behaves under specific conditions — what guarantees hold, what trade-offs apply, and how the mechanism interacts with related techniques. The property is only meaningful when its preconditions are met; outside those conditions it provides no benefit and may add cost.

When to use

Apply Fixture Factory Pattern when designing systems where test data construction matters. It is most useful under partial failure, high load, or correctness requirements. Pair it with observability to verify the claimed behavior in production. Do not assume the property holds without testing the specific configuration and workload.

Common misconceptions

  • Fixture Factory Pattern eliminates all problems in its domain — it only bounds or shapes specific failure modes, not all pathologies.
  • Fixture Factory Pattern is free once you adopt the right tool — the property depends on configuration, workload, and failure pattern, not the product label alone.

Anti-patterns to avoid

  • Enabling Fixture Factory Pattern without measuring its cost in latency, availability, or operational complexity under production-like conditions.
  • Assuming Fixture Factory Pattern composes safely with other guarantees — combining mechanisms can introduce new failure modes or negate benefits.
  • Fixture Isolation (fixture-isolation)
  • Test Doubles (test-doubles)