lemurheavy / coveralls-public

The public issue tracker for coveralls.io
http://coveralls.io
124 stars 7 forks source link

Exclude "tests" files from my coverarge report #1732

Closed buhtz closed 7 months ago

buhtz commented 8 months ago

As an example

https://coveralls.io/github/bit-team/backintime

Python files containing unit tests are part of the report. That makes no sense to me. I am not interested in the coverage of uni test sources. I want to know the coverage of the productive sources.

I am confused why the coverals UI is not able to detect that by itself. How can I configure this?

afinetooth commented 8 months ago

Hi, @buhtz.

Coveralls is agnostic about the coverage reports you send it, which is to say that it takes for granted that they are correct.

The step of excluding files, or specific code lines, from coverage reports is typically done at the level of your code coverage library, in its configuration file.

Assuming your coverage library is coverage.py, you can exclude test files from coverage reports by modifying your .coveragerc file—something like this:

# .coveragerc
[run]
omit =
    */tests/*
    */test_*.py
    *_test.py
    tests.py

(reference)

We used to have a feature that excluded certain directories from coverage reports, but we retired it because it was so rudimentary compared to the patterns and features supported by the configs of code coverage libraries.

afinetooth commented 7 months ago

Hi @buhtz. Were you able to get this to work for you? I'm going to close this, but please re-open if the issue is unresolved.