We're adding unit tests to previously untested code, as the need arises to modify that code. It's difficult to get useful coverage metrics since the majority of code in any package is known to be untested.
Are there any tools available to measure differential code coverage, that is, the percent of code modified in a given changeset which was covered by a unit test?
Use pycobertura. It's a command-line tool to prevent code coverage regression by diffing two coverage reports. It tells you whether your new code is better or worse than the previous version, coverage-wise.
$ pycobertura diff ./master/coverage.xml ./myfeature/coverage.xml
It's language agnostic since it just relies on the Cobertura report (XML file) generated by your testing/coverage tool.
Pycobertura can also generate HTML reports which fit nicely in CI/CD tools such as Jenkins.
https://github.com/aconrad/pycobertura
Continuous integration tools like Jenkins let you keep a history of test coverage and show you a graph that includes a coverage trend compared to previous builds. Example: Cobertura Jenkins Plugin
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