diff --git a/munit/shared/src/main/scala/munit/Assertions.scala b/munit/shared/src/main/scala/munit/Assertions.scala index ef03b49d..5f05d7a5 100644 --- a/munit/shared/src/main/scala/munit/Assertions.scala +++ b/munit/shared/src/main/scala/munit/Assertions.scala @@ -196,8 +196,10 @@ trait Assertions extends MacroCompat.CompileErrorMacro { fail(expectedExceptionMsg) } catch { case e: FailExceptionLike[_] - if !T.runtimeClass.isAssignableFrom(e.getClass()) || - e.getMessage.contains(expectedExceptionMsg) => + if !T.runtimeClass.isAssignableFrom(e.getClass()) => + throw e + case e: FailExceptionLike[_] + if e.getMessage.contains(expectedExceptionMsg) => throw e case NonFatal(e) => if (T.runtimeClass.isAssignableFrom(e.getClass())) { diff --git a/tests/shared/src/test/scala/munit/FailExceptionSuite.scala b/tests/shared/src/test/scala/munit/FailExceptionSuite.scala index 33237a4c..1c4ce12c 100644 --- a/tests/shared/src/test/scala/munit/FailExceptionSuite.scala +++ b/tests/shared/src/test/scala/munit/FailExceptionSuite.scala @@ -8,7 +8,7 @@ class FailExceptionSuite extends BaseSuite { assert(clue(e).isInstanceOf[Serializable]) } -test("assertion-error-no-exception") { + test("assertion-error-no-exception") { try { intercept[AssertionError] { println("throwing no exception!")