fixturesui-testinguitesttest-fixture

What are fixtures in programming?


I have heard of this term many times (in the context of programming) but couldn't find any explanation of what it meant. Any good articles or explanations?


Solution

  • I think you're referring to test fixtures:

    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

    (source: wikipedia, see link above)

    Here are also some practical examples from the documentation of the 'Google Test' framework.