gleeunit icon indicating copy to clipboard operation
gleeunit copied to clipboard

Include stack trace in failed test info

Open danielbom opened this issue 6 months ago • 1 comments

I opened an issue on the Gleam repository about a potential inconsistency in how let assert failures are reported (issue 4703). The behavior differs between gleam run and gleam test.

Here’s an example of the output from gleam test:

test/phone_number_test.gleam
   test: cleans_the_number_test
  error: Pattern match failed
   site: phone_number:9
  value: ["2", "2", "3", "4", "5", "6", "7", "8", "9", "0"]

And from gleam run:

runtime error: let assert

Pattern match failed, no pattern matched the value.

unmatched value:
  ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0"]

stacktrace:
  phone_number.-clean/1-fun-0- src\phone_number.gleam:9

As I noted in the issue:

“It seems like gleam run is much more explicit—it clearly signals that the developer made a wrong assertion, with a red-colored title and a full stack trace (e.g., src\phone_number.gleam:9). On the other hand, gleam test reports the failure more subtly, almost as if everything ran normally.”

Wouldn’t it be a good idea for gleam test to adopt a stricter and more visible approach to let assert failures—similar to gleam run—since these are developer errors that benefit from being highlighted clearly?

danielbom avatar Jun 20 '25 17:06 danielbom

Adding the stack trace sounds good!

The behavior differs between gleam run and gleam test.

There's no expectation for these two distinct projects to have the same output.

lpil avatar Jun 22 '25 15:06 lpil