Skip to content

Commit a829ccc

Browse files
committed
add test using forAll with kotest
1 parent 8b6e9e1 commit a829ccc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

kotlin-testing/src/test/kotlin/testing/style/KotestFreeSpec.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package testing.style
22

33
import io.kotest.core.spec.style.FreeSpec
4+
import io.kotest.inspectors.forAll
45
import io.kotest.matchers.shouldBe
56
import testing.common.DistanceConverter
67
import testing.common.Input
@@ -21,4 +22,19 @@ class KotestFreeSpec : FreeSpec({
2122
}
2223
}
2324
}
25+
26+
fun square(a: Int) = a*a
27+
28+
"squares" {
29+
val testData = listOf(
30+
2 to 4,
31+
3 to 9,
32+
4 to 16,
33+
5 to 25
34+
)
35+
testData.forAll { (input, expected) ->
36+
square(input) shouldBe expected
37+
}
38+
}
39+
2440
})

0 commit comments

Comments
 (0)