Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

Updates: I'll add more definitions of fixture here as when I encounter new ones. That'll be fun.

Alternative definitions

  • (anything that implements the ITestFixture interface) Source: sqa
share|improve this question
add comment

2 Answers

up vote 4 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...

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
1  
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
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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.