What are fixtures in programming?

前端 未结 6 615
闹比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:05

    I'm writing this answer as quick note for myself on what is "fixture".

    same-data-multiple-tests

    Test Fixtures: Using the Same Data Configuration for Multiple Tests If you find yourself writing two or more tests that operate on similar data, you can use a test fixture. This allows you to reuse the same configuration of objects for several different tests.

    you can read more at googletest

    fixtures can be used for during integration test or during development (lets say ui development where data is comming from development database

    fake users for database or testing

    myproject/fixtures/my_fake_user.json

    [
      {
        "model": "myapp.person",
        "pk": 1,
        "fields": {
          "first_name": "John",
          "last_name": "Lennon"
        }
      },
      {
        "model": "myapp.person",
        "pk": 2,
        "fields": {
          "first_name": "Paul",
          "last_name": "McCartney"
        }
      }
    ]
    

    you can read more from django docs

提交回复
热议问题