python test coverage comparison with previous run
Asked Answered
F

1

7

I am using coverage.py to check the code coverage of my unit tests, in form of html report.

coverage run -m pytest
coverage html

The report is pretty cool which shows the overall coverage % and the coverage % of individual .py file. Every time I finished some code changes I would re-run the coverage report to check if my unit test test cases can cover the new codes well. However, the issue is that I have to spot manually if any .py file has particularly low coverage.

Is there any way or existing tool I can use to compare the test coverage with previous/historical run? So that I can easily spot if any .py file has significantly dropped coverage.

Franek answered 24/9, 2019 at 8:22 Comment(1)
Checkouot my solution to a similar questionAbortionist
F
7

This feature is not supported by coverage.py currently, but can be built outside of coverage.py

codecov.io

Services like codecov.io provide this feature

diff-cover

Projects like diff-cover highlight lines in your most recent change that are missing coverage.

The diff-cover command line tool compares an XML coverage report with the output of git diff. It then reports coverage information for lines in the diff.

Franek answered 27/9, 2019 at 7:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.