Terminology – What Are the Different Meanings of ‘Fixture’?

definitionjavaPHPterminologytesting

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.

Best Answer

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...

Related Topic