How can I get an incremental report on code coverage in Python?
By "incremental", I mean what has been the change in the covered lines since some "last" report, or from a particular Git commit.
I'm using unittest
and coverage
(and coveralls.io) to get the code coverage statistics, which work great. But I'm involved only with a part of the project, and at first I'm concerned with what my last commit has changed. I expected coverage
to be able to show the difference between two reports, but so far have not found anything short of running textual diff on HTML output.
Brief
I use pycobertura.
pycobertura diff --format html --output cov_diff.html coverage_old.xml coverage_new.xml
Details
I use the following chain (coverage):
Generate coverage report:
python -m coverage run -m unittest
Output cobertura's XML format:
coverage xml --omit tests/* -o cover_old.xml
-- Modify code or checkout newer commit --
Generate coverage report:
python -m coverage run -m unittest
Output cobertura's XML format:
coverage xml --omit tests/* -o cover_new.xml
Generate diff: pycobertura diff --format html --output cov_diff.html coverage_old.xml coverage_new.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With