From 9cc9c36c53e43927b3a7de1ba6423bbb2482d03b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Zu=CC=88hlke?= Date: Fri, 7 Jul 2023 08:32:34 +0200 Subject: [PATCH] fail the entire suite in case of a fatal exception --- munit/shared/src/main/scala/munit/MUnitRunner.scala | 1 + .../src/main/scala/munit/SwallowedExceptionSuite.scala | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/munit/shared/src/main/scala/munit/MUnitRunner.scala b/munit/shared/src/main/scala/munit/MUnitRunner.scala index 4ce99ec7..a081d81b 100644 --- a/munit/shared/src/main/scala/munit/MUnitRunner.scala +++ b/munit/shared/src/main/scala/munit/MUnitRunner.scala @@ -311,6 +311,7 @@ class MUnitRunner(val cls: Class[_ <: Suite], newInstance: () => Suite) case ex: StackOverflowError => handleNonFatalOrStackOverflow(ex) case ex => + suiteAborted = true notifier.fireTestFailure(new Failure(description, ex)) Future.successful(()) } diff --git a/tests/shared/src/main/scala/munit/SwallowedExceptionSuite.scala b/tests/shared/src/main/scala/munit/SwallowedExceptionSuite.scala index 988a3901..5428270a 100644 --- a/tests/shared/src/main/scala/munit/SwallowedExceptionSuite.scala +++ b/tests/shared/src/main/scala/munit/SwallowedExceptionSuite.scala @@ -10,11 +10,16 @@ class SwallowedExceptionSuite extends FunSuite { test("issue-650") { throw new IllegalAccessError("i am reported") } + + test("should not be executed") { + assertEquals(1, 1) + } } object SwallowedExceptionSuite extends FrameworkTest( classOf[SwallowedExceptionSuite], """|==> failure munit.SwallowedExceptionSuite.issue-51 - i am not reported |==> failure munit.SwallowedExceptionSuite.issue-650 - i am reported + |==> skipped munit.SwallowedExceptionSuite.should not be executed - Suite has been aborted |""".stripMargin )