Lukasz Kalnik
02/11/2025, 9:38 AMwithData()
in isolation mode InstancePerTest
and InstancePerLeaf
doesn't support multiple arguments when one of them is random (or otherwise generated, I'm using Instancio) and the others are based on the first one:
val a = Random.nextInt().toString()
val b = "101$a"
val c = "010$a"
withData(a, b, c) { a -> println("withData: $a") }
prints only the first argument (the test doesn't run for b
and c
):
withData: 1234664241
Lukasz Kalnik
02/11/2025, 9:43 AMLukasz Kalnik
02/11/2025, 9:56 AMclass MyTest : StringSpec({
isolationMode = InstancePerTest
val a = Random.nextInt().toString()
val b = "101$a"
val c = "010$a"
withData(a, b, c) { t -> println("withData: $t") }
})
Lukasz Kalnik
02/11/2025, 10:02 AMLukasz Kalnik
02/11/2025, 10:03 AMInstancePerLeaf
instead, the test doesn't throw, but only executes the test with the first argument.Lukasz Kalnik
02/11/2025, 10:04 AMSingleInstance
it works as expected.Lukasz Kalnik
02/11/2025, 4:41 PMwithData(
mapOf(
"Random" to Random.nextInt().toString(),
// ...
)
) {
// ...
}
Lukasz Kalnik
02/12/2025, 8:46 AMsam
02/12/2025, 4:33 PM