asParameterForEach
infix fun asParameterForEach(content: TestFixture.Scope<suspend Test.ExecutionScope.(value: Value) -> Unit>.() -> Unit): TestFixture<Value>(source)
Provides a fresh value from this fixture as a parameter for each test declared in the content's scope.
Using this function implies a test-level fixture, whose value will be instantiated per test, and has a lifetime of that test. This is safe for concurrent test invocation, because values are isolated.
Usage:
testFixture {
Account().apply { setBalance(42.0) }
} asParameterForEach {
test("add 10.0") { account ->
account.add(10.0)
assertEquals(52.0, account.balance)
}
test("add -10.0") { account ->
account.add(-10.0)
assertEquals(32.0, account.balance)
}
}Content copied to clipboard