Ihar S
03/13/2021, 9:39 PMGiven When Then
- it is covered by BehaviorSpec
• Usage of something similar to Data Tables
from Spock but in Kotest - io.kotest.data.forAll
looks similar
Can anyone please point me to any well written example?
Because I end-up with a callback hell
all the time
Thank you in advance!sam
03/13/2021, 10:39 PMIhar S
03/14/2021, 7:13 PMclass SomeDataTest : BehaviorSpec({
Given("...") {
When("...") {
forAll(
table(
headers("frontPageKey", "pageUrl", "expected result"),
row(null, null, null),
row("key", "key", "something"),
row(null, "something", null),
)
) { key1: String?, key2: String?, expectedResult: String? ->
Then("...") {
}
}
}
}
})
sam
03/14/2021, 8:51 PMdave08
03/15/2021, 3:02 AMsam
03/15/2021, 3:05 AMdave08
03/15/2021, 3:06 AMand
along the way... which makes that harder since when can also have it...)Ihar S
03/15/2021, 9:12 AMdave08
03/15/2021, 9:17 AM"maximum of two numbers"
, then you could just do:
init {
test("maximum of two numbers") {
// given -- maybe the table here?
// when -- run the SUT
// use the forAll
}
}
with those comments there to delimit the sections, but then it just boils down to JUnit with an additional bell-and-whistle of forAll...given()
section that isn't nested, and you can use that there. But it's missing tons of features that Kotest has, and the devotion that's dedicated to it ❤️... the devs really go out of their way to help out in Kotest!Ihar S
03/15/2021, 10:04 AM