abendt
06/20/2022, 3:30 PMfun <K, V> Map<K,V>.shouldMatchAll(vararg matcher: Pair<K, (V) -> Unit>)
Do you think this is generally helpful and would you accept a PR with that matcher?sam
06/20/2022, 3:47 PMabendt
06/21/2022, 7:00 AMerrorCollector.runWithMode(ErrorCollectionMode.Hard)
block is required.
I tried to come up with a testcase that fails if its not there (played with assertSoftly
) however didn't manage.
Could you plese explain the purpose of that block? how to test its use in the implementation?Emil Kantis
06/21/2022, 3:19 PMshouldThrow<AssertionError> {
assertSoftly {
mapOf("key" to "hi") should matchAll("key" to { it shouldHaveLength 4 })
}
}.message shouldBe """
Expected map to match all assertions. Missing keys were=[key], Mismatched values were=[(key, "hi" should have length 4, but instead was 2)].
""".trimIndent()
This test fails with :
Expected :"Expected map to match all assertions. Missing keys were=[key], Mismatched values were=[(key, "hi" should have length 4, but instead was 2)]."
Actual :""hi" should have length 4, but instead was 2"
Due to the message being wrong. The reason the message is wrong is because the inner shouldHaveLength
matcher is not throwing (since we're inside assertSoftly
) and then when the assertSoftly block terminates it throws all captured assertion errors, just giving us the underlying error.abendt
06/21/2022, 3:53 PM