Skip to content

Commit

Permalink
In case of any Throwable inside a test mark the test as failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
mzuehlke authored and tgodzik committed Aug 28, 2023
1 parent 56fbb78 commit becac1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions munit/shared/src/main/scala/munit/MUnitRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ class MUnitRunner(val cls: Class[_ <: Suite], newInstance: () => Suite)
handleNonFatalOrStackOverflow(ex)
case ex: StackOverflowError =>
handleNonFatalOrStackOverflow(ex)
case ex =>
notifier.fireTestFailure(new Failure(description, ex))
Future.successful(())
}
val result: Future[Unit] =
try runTestBody(notifier, description, test).recoverWith(onError)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ class SwallowedExceptionSuite extends FunSuite {
test("issue-51") {
throw new Exception("i am not reported") with NoStackTrace
}

test("issue-650") {
throw new IllegalAccessError("i am reported")
}
}
object SwallowedExceptionSuite
extends FrameworkTest(
classOf[SwallowedExceptionSuite],
"""|==> failure munit.SwallowedExceptionSuite.issue-51 - i am not reported
|==> failure munit.SwallowedExceptionSuite.issue-650 - i am reported
|""".stripMargin
)

0 comments on commit becac1c

Please sign in to comment.