Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some difficulty understanding the concept of "fixture". I know what a test suite is, a test case, a test run, but what exactly is a "fixture"? A parameterized test case?

It seems to me that the meaning or semantics of the term "fixture" can vary slightly by programming language or by testing framework? I think a phpunit fixture

"the code to set the world up in a known state and then return it to its original state when the test is complete. This known state is called the fixture of the test."

is slightly different from a "fitnesse fixture", where

"Fixtures are a bridge between the Wiki pages and the System Under Test (SUT), which is the actual system to test".

Is there an expert in software testing around here who can answer this question? References to other programming languages are welcome.

share|improve this question
@chris (and knb) please put answers in as answers, not edits to the question. – user40980 Jun 8 '15 at 16:36
up vote 10 down vote accepted

In the context of testing tools you mentioned, such as PHPUnit and Fitnesse, this term definitely refers to the notion of test fixture:

something used to consistently test some item, device, or piece of software...


Test fixture refers to the fixed state used as a baseline for running tests in software testing. The purpose of a test fixture is to ensure that there is a well known and fixed environment in which tests are run so that results are repeatable. Some people call this the test context.

Examples of fixtures:

  • Loading a database with a specific, known set of data
  • Erasing a hard disk and installing a known clean operating system installation
  • Copying a specific known set of files
  • Preparation of input data and set-up/creation of fake or mock objects...

Use of fixtures

Some advantages of fixtures include separation of the test initialization (and destruction) from the testing, reusing a known state for more than one test, and special assumption by the testing framework that the fixture set up works...

share|improve this answer
to summarize, a fixture is an object with a known state that tests (or whatever) can proceed with and have expected results. – dave thieben Sep 19 '13 at 14:20
so I'd say a fixture is some kind of abstraction of a test suite. Maybe I was confused because sometimes people use synonymously: the term fixture (the abstraction, or the stateful object at early test-runtime ) and fixture configuration (the configuration saved away to get processed by the setup() methods). – knb Sep 20 '13 at 7:10

Outside of the testing context, the term fixture is sometimes used to describe the initial data in storage (like the initial data in a database) when deploying an application for the first time.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.