testFixture

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 close at the end of its lifetime, otherwise closeWith can 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() }

Use its value in the suite's child elements by invoking the fixture like this:

repository().getScore(...)