Eric
08/05/2022, 5:39 PMwithCaptured
(mockk) breaks assertion chaining if the slot has not been captured. It throws Mapping 'captured value %s' failed with: lateinit property captured has not been initialized
. Not sure if this is known or intentional. Would be nice if instead of throwing it would short circuit the block and fail.Eric
08/05/2022, 5:43 PMfun <T : Any> Assertion.Builder<CapturingSlot<T>>.betterWithCaptured(
block: Assertion.Builder<T>.() -> Unit
): Assertion.Builder<CapturingSlot<T>> =
assertThat("is captured", CapturingSlot<T>::isCaptured)
.with("captured value %s", CapturingSlot<T>::captured, block)
Eric
08/05/2022, 5:57 PMfun <T : Any> Assertion.Builder<CapturingSlot<T>>.withCaptured(
block: Assertion.Builder<T>.() -> Unit
): Assertion.Builder<CapturingSlot<T>> =
isCaptured().with("captured value %s", CapturingSlot<T>::captured, block)
robfletcher
08/05/2022, 7:47 PMEric
08/08/2022, 3:38 PMfun <T> Assertion.Builder<T>.verify(
ordering: Ordering = Ordering.UNORDERED,
inverse: Boolean = false,
atLeast: Int = 1,
atMost: Int = Int.MAX_VALUE,
exactly: Int = -1,
timeout: Long = 0,
verifyBlock: MockKVerificationScope.() -> Unit
): Assertion.Builder<T> = assert("mockk passes verification") {
try {
io.mockk.verify(ordering, inverse, atLeast, atMost, exactly, timeout, verifyBlock)
pass()
} catch (e: AssertionError) {
fail(e.message?.substringBefore("Stack trace:"))
}
}
robfletcher
08/08/2022, 4:20 PMEric
08/08/2022, 4:21 PMrobfletcher
08/08/2022, 4:21 PM