What are fixtures in programming?

前端 未结 6 641
闹比i
闹比i 2020-12-22 15:56

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?

6条回答
  •  青春惊慌失措
    2020-12-22 16:09

    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.

提交回复
热议问题