Fixtures#
Fixture is a standard concept in pytest and in sofeshare testing in general.
In the context of Estshizard, a fixture is a procedure that prepares the test environment before running a test and/or finalizes it after completion.
Before a test starts, a fixture may configure required resources, create temporary files or data, etc., thus ensuring the environment in which the test can run correctly. After the test finishes, the fixture is responsible for cleanup and restoring the initial state, e.g. deleting temporary data.
To make a test use a fixture, a parameter named after the fixture is added to it. The framework, upon receiving information about the test’s fixtures, executes them before running the test itself. Fixtures themselves can also be parameterized, in which case they will be invoked multiple times, each time executing a set of dependent tests, i.e. tests that depend on that fixture.
The parameterization mechanisms of fixtures and tests in pytest have some differences. This is reflected, among other things, in how test names are formed. When parameterizing tests, each parameter is displayed separately in the test run name, e.g. test[FOO=1-BAR=2]. For fixture parameterization, so-called indirect parameterization is used. In this case, the parameter set for a specific run is aggregated into a special container and displayed in the test run name as Indirect.
Currently, users cannot define their own fixtures, but fixtures are used in the new dependency handling mechanism.