test fixture

Fixed, known data or setup that tests use so their results are predictable, such as a sample file, a seeded database or a started application.

In more detail

Fixtures keep tests independent of the outside world, make results reproducible and avoid repeating expensive setup. Testing tools offer different mechanisms for them, from plain data files to setup functions and classes.

Examples

xUnit: IClassFixture<WebApplicationFactory<Program>>
func (Fixture) Read() string { return "fixture data" }
Go: fixture files conventionally live in a testdata folder
type Fixture struct{} returns fixed data through an interface

Related terms

Taught in

References

Certification courses