test fixture
Domain: Testing Quality
π― Motivation
A test fixture provides reusable setup data or objects for multiple tests. Fixtures keep tests DRY (Donβt Repeat Yourself) by centralizing preparation steps like creating a database connection or sample data.
π Concrete Example
In pytest, you define @pytest.fixture def sample_user(): return {"name": "Alice"}, and any test function that accepts sample_user as a parameter receives the same dict.
π Analogy
A test fixture is like a stage crew that sets up the props before each scene. The actors (tests) just walk on and perform, without building their own furniture.