Currently if some code wants to handle assertion failures, this doesn't work for strikt helpers like first() because MappingException extends IncompleteExecutionException, not AssertionError. eg:
private val failures = mutableListOf<AssertionError>()
fun doSomethingWithFailures(runnable: Runnable) {
try {
runnable.run()
} catch(assertionFailed: AssertionError) {
failures.add(assertionFailed)
throw assertionFailed
}
}
private fun thingUnderTest() = emptyList<String>()
// failure will be added to failures
@Test
fun `thingUnderTest has a catflap`() {
doSomethingWithFailures {
expectThat(thingUnderTest()).contains("catflap")
}
}
// failure will not be added to failures
@Test
fun `thingUnderTest has a catflap first`() {
doSomethingWithFailures {
expectThat(thingUnderTest()).first().isEqualTo("catflap")
}
}
Would it be better to have MappingException extend org.opentest4j.AssertionFailedError instead?
Currently if some code wants to handle assertion failures, this doesn't work for strikt helpers like
first()
becauseMappingException
extendsIncompleteExecutionException
, notAssertionError
. eg:Would it be better to have
MappingException
extendorg.opentest4j.AssertionFailedError
instead?