From 41b70f2d7bc5346226333264eb83e22415cb308f Mon Sep 17 00:00:00 2001 From: Ben Woodworth Date: Fri, 17 May 2024 20:56:13 -0400 Subject: [PATCH] WIP Replace kotest-property with parameterize --- src/commonTest/kotlin/test/parameterizeTest.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/commonTest/kotlin/test/parameterizeTest.kt b/src/commonTest/kotlin/test/parameterizeTest.kt index b4279b4e..731b2a99 100644 --- a/src/commonTest/kotlin/test/parameterizeTest.kt +++ b/src/commonTest/kotlin/test/parameterizeTest.kt @@ -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 = { @@ -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)