testFixture
fun <Value : Any> testFixture(value: suspend TestSuite.() -> Value): TestSuite.Fixture<Value>(source)
Registers a fixture, a state holder for a lazily initialized Value with a lifetime of this test suite.
Characteristics:
The fixture is lazily initialized on first use by the value lambda.
If Value is an AutoCloseable, the fixture will call
closeat the end of its lifetime, otherwisecloseWithcan specify an action to be called on close.All test elements within its suite share the same fixture value.
Usage:
Register a fixture at the suite level like this:
val repository = testFixture { MyRepository(this) } closeWith { disconnect() }Content copied to clipboard
Use its value in the suite's child elements by invoking the fixture like this:
repository().getScore(...)Content copied to clipboard