Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python test coverage comparison with previous run

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.

like image 817
henrywongkk Avatar asked Oct 16 '22 11:10

henrywongkk


1 Answers

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.

like image 106
henrywongkk Avatar answered Nov 03 '22 06:11

henrywongkk