Skip to content
>devspeak
← glossary
level 6Testing & Reliability

Fixture

also: fixtures, test fixture, test fixtures

Prepared sample data or setup that tests start from, like a few fake users and orders loaded before each test runs.

a bit more technical

A fixed, known starting state for tests: sample records, files, or setup and cleanup code, such as seeding a test database with three users. Fixtures make tests repeatable because every run starts from the same place.

picture it

A cooking show's pre-measured ingredients in little bowls. Every take starts with exactly the same ingredients, so the results are comparable.

why it matters

When an agent's tests depend on data, the fixtures decide what "normal" looks like. If fixtures only contain tidy data, tests never see the messy cases your real users create.

what your agent might say
agent
I added a fixture with 3 sample recipes, including one with no ingredients. Each test loads it into a fresh test database.
how you might use it
you → your agent
Create fixtures for the order tests that include a refunded order, an order with zero items, and a customer with no email address.
common mistake

Thinking a fixture fakes part of the system. That's a mock. A fixture is the data or setup a test starts from; the code being tested is still real.

builds on