Test fixture
A test fixture is the prepared state required to run a test — input data, mocked dependencies, configured environment, seeded database rows. Fixtures separate the 'arrange' setup from the 'act' and 'assert' phases of the test, making the test's intent clearer.
Fixture quality is a leading indicator of test-suite quality. Good fixtures are small (only the data the test needs), focused (one fixture per scenario, not one giant shared one), and named meaningfully (validOrder, expiredCoupon, suspendedUser). Bad fixtures are large (every test loads the same 200-row dataset), generic (a fixture used across 50 tests with subtle variations), or magic (the test fails when a seemingly unrelated field changes). Fixture design parallels test design: if writing a clear fixture is hard, the underlying code is often too coupled.
Related terms
- Test data management
Test data management is the discipline of producing, maintaining, and isolating the data used in tests — fixtures, factories, seeded databases, anonymised production snapshots.
- Test double
A test double is any object that stands in for a real dependency in a test — mock, stub, fake, spy, dummy.
- Test isolation
Test isolation is the property that each test runs independently — no shared state, no execution-order dependency, no side effects bleeding to the next test.