kotest-property / io.kotest.property / checkCoverage

checkCoverage

suspend fun checkCoverage(label: String, percentage: Double, f: suspend () -> PropertyContext): PropertyContext

Asserts that the given label was applied to at least percentage number of tests. See PropertyContext.classify.

Example, checks that for at least 25% of the iterations a was classified as "even".

    checkCoverage("even", 25.0) {
       forAll(Arb.int()) { a ->
          classify(a % 2 == 0, "even")
          a + a == 2 * a
       }
    }
suspend fun checkCoverage(vararg pairs: Pair<String, Double>, f: suspend () -> PropertyContext): PropertyContext

Asserts more than one label coverage at once.

Example, checks that we had at least 25% "even" and 25% "odd" iterations.

    checkCoverage("even" to 25.0, "odd" to 25.0) {
       forAll(Arb.int()) { a ->
          classify(a % 2 == 0, "even", "odd")
          a + a == 2 * a
       }
    }