I needed some quick unit testing for a library, to rule out a run-time error. In the end, it wasn’t that complicated, but the “straightforward” way of implmenting unit testing with haskell/cabal isn’t as straightforward as it could be.
I ended up implementing this guy’s solution (stackoverflow.com, 8 years ago):
… which is a combination of
test-framework
, HUnit
, test-framework-hunit
with cabal Test Suite exitcode-stdio-1.0
.
It does exactly what I needed, only the following things felt a bit awkard:
- What is this alternative cabal test suite
detailed-0.9
? Documentation is slim. When should I use one over the other? - Those three libraries are fine, I guess, but given the basic nature of the task: Why isn’t it just one thing? I tried working with
HUnit
alone, BUTexitcode-stdio-1.0
requires working with exit codes that I have to put in place manually … thus I prefer thedefaultMain
fromtest-framework
.
I certainly don’t mean to complain. Maybe there is a more straightforward way of implementing unit testing that I overlooked.
If, however, this is how it’s done, I hope this posts contributes to the documentation of the topic.