From 8181ceb4841f073155060b62421c4bce9199c5de Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Thu, 28 Nov 2024 15:21:10 +0100 Subject: [PATCH] bugfix: Print stack trace for assertEquals Not sure why not show the stack trace and it's rather unexpected Fixes https://github.com/scalameta/munit/issues/782 --- munit/shared/src/main/scala/munit/Assertions.scala | 2 +- .../src/main/scala/munit/StackTraceFrameworkSuite.scala | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/munit/shared/src/main/scala/munit/Assertions.scala b/munit/shared/src/main/scala/munit/Assertions.scala index 54f33aa7..cd03f472 100644 --- a/munit/shared/src/main/scala/munit/Assertions.scala +++ b/munit/shared/src/main/scala/munit/Assertions.scala @@ -275,7 +275,7 @@ trait Assertions extends MacroCompat.CompileErrorMacro { obtained, expected, loc, - isStackTracesEnabled = false + isStackTracesEnabled = true ) } diff --git a/tests/shared/src/main/scala/munit/StackTraceFrameworkSuite.scala b/tests/shared/src/main/scala/munit/StackTraceFrameworkSuite.scala index 118bc921..8ba7522e 100644 --- a/tests/shared/src/main/scala/munit/StackTraceFrameworkSuite.scala +++ b/tests/shared/src/main/scala/munit/StackTraceFrameworkSuite.scala @@ -28,6 +28,9 @@ object FullStackTraceFrameworkSuite extends BaseStackTraceFrameworkSuite( Array("-F"), """|at munit.Assertions:failComparison + | at munit.Assertions:failComparison$ + | at munit.FunSuite:failComparison + | at munit.Assertions$$anon$1:handle |==> failure munit.StackTraceFrameworkSuite.fail - tests/shared/src/main/scala/munit/StackTraceFrameworkSuite.scala:5 |4: test("fail") { |5: assertNoDiff("a", "b") @@ -44,7 +47,9 @@ object FullStackTraceFrameworkSuite object SmallStackTraceFrameworkSuite extends BaseStackTraceFrameworkSuite( Array(), - """|at munit.Assertions:failComparison + """|at munit.FunSuite:assertNoDiff + | at munit.StackTraceFrameworkSuite:$anonfun$new$1 + | at scala.runtime.java8.JFunction0$mcV$sp:apply |==> failure munit.StackTraceFrameworkSuite.fail - tests/shared/src/main/scala/munit/StackTraceFrameworkSuite.scala:5 |4: test("fail") { |5: assertNoDiff("a", "b")