willowtreeapps / assertk

assertions for kotlin inspired by assertj
MIT License
757 stars 84 forks source link

prioritize exceptions thrown directly in soft assertion blocks #503

Closed evant closed 8 months ago

evant commented 8 months ago

If you had

assertAll {
  assertThat(1).isEqualTo(2)
  throw IllegalStateException("Broken!")
}

the IllegalStateException would be swallowed. It'll now be the primary exception you see. This more closely matches the mental model where soft assertions are thrown at the end of the block.

For convenience the assertion failure is added as a suppressed exception. Kotlin has mixed support for this (jvm shows the suppressed exception trace and error message, native just shows the trace, and js doesn't show it at all). This is acceptable as the inline exception is likely the one you care about fixing anyway.

Fixes #475