Test Fixture

Noun · Development

Definitions

  1. The fixed state used as a baseline for running tests — test data, mock objects, configuration, database records, and environment setup. Fixtures run before each test (setup) and clean up after (teardown). Can be function-scoped (fresh per test), module-scoped, or session-scoped. pytest fixtures are the gold standard for composable test setup.

    In plain English: The setup work (creating test data, configuring mocks) that runs before each test to put things in a known state.

    Example: "The @pytest.fixture creates a test database with seed data — each test gets a fresh transaction that's rolled back after the test."

Related Terms