Search code examples
haskellhunit

How do I make HUnit print linebreaks in assertion failures?


Some of my HUnit tests compare fairly large structures with assertEqual. It's hard to spot errors in these since HUnit prints the strings on one line. What I'd like to do is use Text.Groom to pretty print these structures, but if I pass a string to assertEqual the line breaks are displayed as \n so it makes the output even harder to read.

How do I make HUnit, assertEqual in particular, print the groomed strings with linebreaks?


Solution

  • assertEqual is just a call to assertBool with the equality comparison as the Bool and the shown version of your data structures as the String. So write yourself a function that calls assertBool with a different error string and you're done.