Kelly Mears

Test Fixture

The prepared data or state a test runs against.

Testing & Verification1 min read194 words11 out · 13 in
also calledFixturesTest data

A test fixture is the prepared input a test needs: a sample record, a rendered document, a seeded database, a drawn image. Fixtures are where a surprising number of tests go quietly wrong, because a fixture chosen for convenience can make an assertion meaningless.

The failure has a general shape: the fixture already satisfies the property being asserted, for reasons unrelated to the code. A layout test using an image wider than its container passes whether or not the layout code works, because a shrink-to-fit box and a spanning box produce the same width in that case. Drawing a deliberately narrow fixture makes the two outcomes different, and the assertion real. A scroll test in a container with no height constraint passes vacuously. See Vacuous Truth.

Two further notes. Fixtures should be local and deterministic where the assertion is about behavior — a remote image introduces network variance and decode noise into what should be a pure comparison. And a helper that merges overrides into a base fixture must merge before pruning explicitly-absent keys, or every attempt to blank a field silently keeps the base value and every negative-path test becomes a happy path.

See also10

Test Double

A stand-in for a real dependency during a test — and the ways a stand-in can lie.

Testing & Verification18 connections

Seed Data

Initial content created programmatically to make an empty system usable or demonstrable.

Data & Content14 connections

Visual Regression Testing

Comparing rendered output against a stored baseline to catch unintended visual change.

Testing & Verification14 connections

Record and Replay Testing

Capturing a real interaction once and replaying it deterministically in later test runs.

Agents & Language Models14 connections

Integration Test

A test exercising several components together, through real interfaces rather than doubles.

Testing & Verification17 connections

Unit Test

A fast, isolated test of one unit of behavior with its collaborators replaced.

Testing & Verification25 connections

Nondeterminism

The property that identical inputs may produce different outputs, and what it costs to test around.

Agents & Language Models24 connections

Determinism

The property that identical inputs produce identical outputs, and the foundation of caching and verification.

Systems & Tooling61 connections

Test Isolation

The property that each test passes or fails on its own, regardless of which other tests run, in what order, or in parallel.

Testing & Verification20 connections

Test Data Builder

Helpers that build valid test objects from sensible defaults so each test states only the fields it cares about, and the Object Mother pattern they grew out of.

Testing & Verification9 connections

Linked from13