assertk / assertk.assertions / exactly

exactly

(common, jvm) fun <E, T : Iterable<E>> Assert<T>.exactly(times: Int, f: (Assert<E>) -> Unit): Unit

Asserts on each item in the iterable, passing if exactly times items pass. The given lambda will be run for each item.

assert(listOf(-1, 1, 2)).exactly(2) { it.isPositive() }