Running stack test --coverage
generates a nice HTML report showing what lines your test suite covers. How can I achieve the same thing using cabal new-test
?
I'm able to pass --enable-coverage
to generate a .tix
file but I'm not sure what to run on the .tix
file to generate the HTML report. I'm pretty sure it involves hpc
but I haven't been able to work out the right command.
I have the standard Cabal configuration of my application being a library, with a test-suite for that library.
Cabal 3.6 should be able to generate the HPC report. There is one caveat; this error may appear:
https://github.com/haskell/cabal/issues/6440
To avoid the error, add to
cabal.project
:then
cabal test
(without--enable-coverage
). The report should be somewhere indist-newstyle
.