UnkindPartition / tasty

Modern and extensible testing framework for Haskell
640 stars 110 forks source link

Assertion failures don't show full stacktrace #350

Open smatting opened 2 years ago

smatting commented 2 years ago

It can be hard to figure out where in a test case assertions are failing. For example if the test case has multiple call sites of a helper function that might fail it's impossible to figure out which call site is raising the HUnitFailure, because only the lower most SrcLoc of the callstack is shown.

I propose to always include the full stack trace in HUniFailure.

Without a full stackrace you can be lost:

Tests
  Auth
    LoginId parser: valid email: FAIL
      test/unit/Test/Wire/API/User/Auth.hs:34:
      Some assertion failed. Try to find me!

In contrast:

Tests
  Auth
    LoginId parser: valid email: FAIL
      Error message: Some assertion failed. Try to find me!

      CallStack (from HasCallStack):
        assertFailure, called at test/unit/Test/Wire/API/User/Auth.hs:52:11 in main:Test.Wire.API.User.Auth
        helper2, called at test/unit/Test/Wire/API/User/Auth.hs:49:10 in main:Test.Wire.API.User.Auth
        helper, called at test/unit/Test/Wire/API/User/Auth.hs:34:3 in main:Test.Wire.API.User.Auth