I’m writing some tests using HUnit and I would like to assert that a particular function throws an exception given a certain input. I can’t find an assert function which provides the required functionality. Anyone know of a test framework that does?
Share
Although HUnit doesn’t come with any exception assertions, it’s easy to write your own:
You can do something more fancy like using a predicate instead of explicit comparison if you like.
Note that
evaluatehere might get optimized away (see GHC ticket #5129), but for testing code in theIOmonad this should work fine.