thanksforallthefish
03/25/2021, 1:51 PMimport io.kotest.core.datatest.forAll
import io.kotest.core.spec.style.StringSpec
import io.kotest.data.Row2
import io.kotest.data.row
import io.kotest.matchers.shouldBe
class ParticipantRoleTest : StringSpec({
"create from string" {
forAll<Row2<String, *>>(
"DamageCauser" to row("DamageCauser", ParticipantRole.DamagingParty),
"Customer" to row("Customer", ParticipantRole.PolicyHolder),
"Unknown" to row("Unknown", ParticipantRole.Other),
"Repairer" to row("Repairer", ParticipantRole.Repairer),
) { (input, output) ->
ParticipantRole.fromString(input) shouldBe output
}
}
})
this does nothing, tests are not executed
but
import io.kotest.core.datatest.forAll
import io.kotest.core.spec.style.FunSpec
import io.kotest.data.Row2
import io.kotest.data.row
import io.kotest.matchers.shouldBe
class ParticipantRoleTest : FunSpec({
context("create from string") {
forAll<Row2<String, *>>(
"DamageCauser" to row("DamageCauser", ParticipantRole.DamagingParty),
"Customer" to row("Customer", ParticipantRole.PolicyHolder),
"Unknown" to row("Unknown", ParticipantRole.Other),
"Repairer" to row("Repairer", ParticipantRole.Repairer),
) { (input, output) ->
ParticipantRole.fromString(input) shouldBe output
}
}
})
generates 4 tests as expectedimport io.kotest.core.datatest.forAll
import io.kotest.core.spec.style.FunSpec
import io.kotest.data.Row2
import io.kotest.data.row
import io.kotest.matchers.shouldBe
class ParticipantRoleTest : FunSpec({
test("create from string") {
forAll<Row2<String, *>>(
"DamageCauser" to row("DamageCauser", ParticipantRole.DamagingParty),
"Customer" to row("Customer", ParticipantRole.PolicyHolder),
"Unknown" to row("Unknown", ParticipantRole.Other),
"Repairer" to row("Repairer", ParticipantRole.Repairer),
) { (input, output) ->
ParticipantRole.fromString(input) shouldBe output
}
}
})
also does nothing, maybe I am really missing something in the docs https://kotest.io/docs/framework/data-driven-testing.html