Skip to content

Don't show the omitted files in the Test Coverage Toolbar #24366

Description

I like the new Test Coverage Toolbar feature. I use it with Python and Coverage.py run via pytest and pytest-cov plugin.

Coverage.py enables omitting some files using globs (e.g. configuration modules or development scripts; see docs). I think that NOT showing those files in the toolbar could be an interesting enhancement.

Sorry if you find this issue biased to Python. I am not so familiar with other languages and testing tools available for them.

Activity

  1. eleanorjboyd commented on Oct 30, 2024

    @eleanorjboyd
    Member

    good idea yes! I can do this specifically on the python side. This will need development time so just putting it for community feedback to see how many people are hitting this issue

  2. github-actions commented on Oct 30, 2024

    @github-actions

    Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

  3. eleanorjboyd commented on Oct 30, 2024

    @eleanorjboyd
    Member

    "Run Test with Coverage" should allow omitting files from the report. Ideally, honor the "omit" setting in the coverage configuration. Some default arguments may be set, such as .venv.

    It seems this can be done using a workaround, namely, by using tool.coverage.run.omit (as opposed to tool.coverage.report.omit, which I tried previously).

    [tool.coverage.run]
    omit = [
        ".venv/*",
        # https://github.com/nedbat/coveragepy/issues/1392
        "pyscript",
        "shibokensupport/*",
        "signature_bootstrap.py",
    ]
    

    copied from #24309 as both are related to omitting files for coverage

  4. eleanorjboyd commented on Nov 13, 2024

    @eleanorjboyd
    Member

    Hi Kamil Paduszyński (@paduszyk)! In what way did you configure your file to omit? I did the most basic setup and it worked for me:

    Image

  5. paduszyk commented on Nov 15, 2024

    @paduszyk
    Author

    Eleanor Boyd (@eleanorjboyd) Actually, I configure the omit option in [report] section, not [run]. In fact, Coverage.py accepts both cases:

    https://coverage.readthedocs.io/en/7.6.5/config.html#run-omit
    https://coverage.readthedocs.io/en/7.6.5/config.html#report-omit

    But, to be honest, the difference is not clear to me. I use the latter, as it sounds more logical to me to use report section to affect the behavior referred to coverage reports.

    Besides, I prefer pyproject.toml as the configuration "hub". I don't think however this can be an issue here.

  6. 9 remaining items

  7. eleanorjboyd commented on Dec 2, 2024

    @eleanorjboyd
    Member

    Verification Steps:

    1. create repo with tests
    2. install pytest and pytest-cov
    3. create a pyproject.toml with this
    [tool.coverage.report]
    # Specify files or patterns to omit from the coverage report
    omit = [
        "tests/*",          # Omit all test files
    ]
    
    1. create a tests folder, add a test in there
    2. run all tests and then check the coverage bar to make sure you don't see the files in the tests folder in the UI
  8. roblourens commented on Dec 6, 2024

    @roblourens
    Member

    I think I still see it, not sure if I did it right?

    Image

  9. eleanorjboyd commented on Dec 6, 2024

    @eleanorjboyd
    Member

    I found the error- this works for omit when it is a specific file

    [tool.coverage.report]
    # Specify files or patterns to omit from the coverage report
    omit = [
        "tests/test_ex.py",          # Omit all test files
    ]
    

    not for a pattern

    [tool.coverage.report]
    # Specify files or patterns to omit from the coverage report
    omit = [
        "tests/*.py",          # Omit all test files
    ]
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-testingbugIssue identified by VS Code Team member as probable bugneeds PRReady to be worked onverifiedVerification succeeded

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions