Skip to content

cabal and integration tests or how to get code coverage for binaries #3902

Open
@sophie-h

Description

@sophie-h

My project structure:

  • library
  • binary (depends library)
  • unit tests
  • integration tests (written in pytest)

The integration tests call the binary. To get code coverage for those calls, I tried to call pytest via system from an extra cabal test-suite. Turns out that this doesen't help. Also wrapping the binary into the test-suite (details) does not help. Seems like only the call from cabal test counts into the coverage report.

So I went back to calling the binary directly and generating reports via hpc manually. First problem: I need to add an obscure --hpcdir for the library (dist/hpc/dyn/mix/<bin>-<version>/<random stuff>/). Second: I get 100% (0/0) coverage. So the library is not included in the report of the binary?

This was all working when I didn't had the split into library/binary. Is it really impossible to build a binary+library with working coverage via cabal?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions