Similarly to how quickcheck supports counterexamples:
property \x ->
counterexample ("Foo failed with: " ++ ...) $
foo x
but in a way that it works with shouldBe, e.g.
failDetails (" details: " ++ baz a) $
a `shouldBe` 2
And I would like it to print something along the lines of:
expected: 2
but got: 3
details: ...
Yes, it seems to be possible:
We catch the exception thrown by
shouldBe, amend the message, and rethrow it.We can even use it like:
if we define: