TestFixture
A test fixture is a state holder for a lazily initialized Value to be used in tests.
Fixtures come in two flavors:
A suite-level fixture provides a value with a lifetime of the test suite it was registered in. Its value is
obtained by invoking the fixture, or
passed as a context (receiver) to tests in the scope of asContextForAll, or
passed as a parameter to tests in the scope of asParameterForAll.
All test elements within its suite share the same value from a suite-level fixture.
A test-level fixture provides its value to each single test with a lifetime of that test. Its value is passed
as a context (receiver) to tests in the scope of asContextForEach, or
as a parameter to tests in the scope of asParameterForEach.
Each test gets its own fresh value from a test-level fixture.
Common characteristics:
The fixture lazily initializes its value on first use via the value lambda.
The value lambda can return any Kotlin object. The
objectexpression can be used to return an anonymous composite value.The value lambda is suspending. To create additional coroutines inside, see TestSuite.testSuiteCoroutineScope for details.
If Value is an AutoCloseable, the fixture will call
closeat the end of its lifetime, otherwise closeWith can specify an action to be called on close.A fixture can be used either as a suite-level fixture, or as a test-level fixture, but not both.
Usage:
For a suite-level fixture, see invoke, asContextForAll and asParameterForAll.
For a test-level fixture, see asContextForEach and asParameterForEach.
Functions
Provides the value from this fixture as a context for all tests declared in the content's scope.
Provides a fresh value from this fixture as a context for each test declared in the content's scope.
Provides the value from this fixture as a parameter for all tests declared in the content's scope.
Provides a fresh value from this fixture as a parameter for each test declared in the content's scope.