How can I show the exception's message as a clue with
shouldNotThrowAny
?
s
sam
11/29/2021, 1:32 PM
Isn't that matcher just the same as not having one
s
Sebastian Schuberth
11/29/2021, 1:50 PM
Not quite, as it swallows the original exception message it seems:
Sebastian Schuberth
11/29/2021, 1:51 PM
Copy code
inline fun <T> shouldNotThrowAny(block: () -> T): T {
assertionCounter.inc()
val thrownException = try {
return block()
} catch (e: Throwable) {
e
}
throw failure(
"No exception expected, but a ${thrownException::class.simpleName} was thrown.",
thrownException
)
}