Questions tagged [fixture]

Fixed state(s) for software under test, also known as text context

In software testing, a test fixture is a fixed state of the software under test used as a baseline for running tests; also known as the test context. It may also refer to the actions performed in order to bring the system into such a state.

It is often used in and .

Examples of fixtures:

  • Loading a with a specific, known set of
  • 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 objects
  • Software used to systematically run reproducible tests on a piece of software under test is known as a test; part of its job is to set up suitable test fixtures.

Source

132 questions
6
votes
2 answers

Can I use a pytest fixture in the condition of my skipif logic?

I am trying to use a pytest fixture (scope=module) in a class skipif decorator, but I am getting an error saying the fixture is not defined. Is this possible? conftest.py has a fixture with module scope called 'target' that returns a CurrentTarget…
5
votes
1 answer

Dynamically parametrizing class-level fixtures with pytest

It is possible to parametrize test functions from command-line arguments. It is possible to have a fixture scoped to a class. I want to combine those two things, so that each class receives parametrized arguments that are given to the fixture within…
dWitty
  • 494
  • 9
  • 22
5
votes
2 answers

pytest parametrized fixture - parameters from json?

Sample code from pytest.org, is it possible to load params from a json file? # content of conftest.py import pytest import smtplib @pytest.fixture(scope="module", params=["smtp.gmail.com", "mail.python.org"]) def smtp(request): …
Eric Chang
  • 83
  • 1
  • 1
  • 5
5
votes
7 answers

Is it possible with Fixture to create a list of N objects?

I want to create with Fixture a list of N objects. I know I can do it with: List persons = new List(); for (int i = 0; i < numberOfPersons; i++) { Person person = fixture.Build().Create(); persons.Add(person); } Is…
4
votes
1 answer

Pytest fixture: setup, teardown and code running between each test

I am trying to use pytest to test a module I am writing. The module is a wrapper of a process with a LONG startup time. I, therefore, want to make sure I have a proper setup/teardown logic to make sure the initialization does not happen more than…
hirolau
  • 13,451
  • 8
  • 35
  • 47
4
votes
0 answers

How can I include fixtures within mongoid?

I have used factory girl and now I relealized fxiture is a better design, thus I decided to change to fixture. However, I used mongoid for my database but mongoid doesn't provide fixuter support. I created my project with command rails new…
Run
  • 876
  • 6
  • 21
4
votes
2 answers

Reference another fixture without using label rails

I have this model called Region and Admin # regions.yml one: name: test two: name: test2 # admins.yml one: name: admin1 two: name: admin2 There's a column on admin.rb defined as json column (store_accessor: :region_ids). How can I…
OmomSun
  • 337
  • 2
  • 15
4
votes
2 answers

Regenerate YAML Fixtures from DB in Rails

I am using Rails and my YAML fixtures are corrupted and unusable. I would like to regenerate the YAML fixtures based on the development database. I am not trying to take all the DB data and turn it into a fixture. What I want is to recreate the…
Jo.P
  • 1,139
  • 4
  • 15
  • 35
4
votes
1 answer

Fixtures for Google App Engine

Are there any Python tools to create fixtures on Google App Engine? I tried Fixture(http://farmdev.com/projects/fixture/). It is the most awesome tool I have come across. I love the clean approach and the consistency of the APIs. But it is LGPL…
Madhusudan.C.S
  • 831
  • 1
  • 7
  • 19
4
votes
2 answers

Rails doesn't generate created_at for fixture

I have a model Question with "question_id", "elapsed_time", "allowed_time" and "status" as its fields and a controller named Reporting that receive JSON containing questions and save it. ("question_id" is not related to any of my models) So far…
VinZen
  • 313
  • 3
  • 13
4
votes
2 answers

Django fixture in csv

For a Django test I'd like to load a fixture, which is in a csv file. What is the best way to do that?
Szymon Lipiński
  • 27,098
  • 17
  • 75
  • 77
3
votes
2 answers

Are there any .net equivalents to Rails fixtures?

I'm looking for a project/tool that will insert data into a database before a test and roll it back after a test has run. I know that ruby on rails has yaml fixtures, so I was hoping there is a project out there for .net projects.
Eric Neunaber
  • 431
  • 3
  • 10
3
votes
2 answers

Symfony 3 - Database static data in production. Fixture ? Migration ? Something else?

As much as I know, a fixture is "something used to consistently test some item, device, or piece of software". It should be used only in dev and test environnement. My context : I have a web app which proposes to sell 5 specific products. There is…
Dam Fa
  • 448
  • 4
  • 16
3
votes
1 answer

py.test: How to generate tests from fixtures

I'm writing a set of tools to test the behavior of a custom HTTP server: whether it is setting appropriate response codes, header fields etc. I'm using pytest to write tests. The goal is to make requests to several resources, and then evaluate the…
David
  • 166
  • 8
3
votes
0 answers

In pytest, when using 'usefixtures', are the fixtures executed in order?

For example, if I have: @pytest.mark.usefixtures("fixture1", "fixture2", "fixture3") class TestFunction: ......... Let's say fixture1, fixture2 and fixture3 are independent class level fixtures. Is it true that the execution order is always…
Hao Shen
  • 2,605
  • 3
  • 37
  • 68
1
2
3
8 9