truthish icon indicating copy to clipboard operation
truthish copied to clipboard

Feature Request: Support assertThrows with a message

Open bitspittle opened this issue 3 years ago • 0 comments

Currently, all the assertThat methods have assertWithMessage versions.

assertThrows is kind of special and I don't think we can do quite the same thing, but there should be some way to add support for a custom message.

I had a loop in some of my code that tested several inputs against an assertThrows check, but when one of them failed, I didn't have any idea of which one. It would have been nice to do something like

for (badInput in listOf(...)) {
   assertThrows<...>("Testing exceptions for input case $badInput...") { ... }
}

bitspittle avatar Apr 01 '22 20:04 bitspittle