Skip to content

Commit

Permalink
WIP Replace kotest-property with parameterize
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWoodworth committed May 18, 2024
1 parent b549697 commit 41b70f2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/commonTest/kotlin/test/parameterizeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package net.benwoodworth.knbt.test
import com.benwoodworth.parameterize.ExperimentalParameterizeApi
import com.benwoodworth.parameterize.ParameterizeScope
import com.benwoodworth.parameterize.parameterize
import kotlin.test.DefaultAsserter.fail

inline fun parameterizeTest(
recordFailures: Long = 10,
maxFailures: Long = Long.MAX_VALUE,
block: ParameterizeScope.() -> Unit
) {
var emptyTest = true
var hasTestCases = false

parameterize(
onFailure = {
Expand All @@ -19,12 +18,12 @@ inline fun parameterizeTest(
}
) {
block()
emptyTest = false
hasTestCases = true
}

if (emptyTest) {
fail("Bad parameterized test: All test cases skipped")
}
// There were no failures if it made it to this point, but check
// just in case all test cases were skipped to empty parameters.
check(hasTestCases) { "Bad parameterized test: All test cases skipped" }
}

@OptIn(ExperimentalParameterizeApi::class)
Expand Down

0 comments on commit 41b70f2

Please sign in to comment.