Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

differential code coverage

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?

like image 587
Michael Brewer-Davis Avatar asked Sep 02 '11 15:09

Michael Brewer-Davis


2 Answers

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.

enter image description here

https://github.com/aconrad/pycobertura

like image 162
Alex Conrad Avatar answered Sep 28 '22 13:09

Alex Conrad


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

like image 34
Sean Patrick Floyd Avatar answered Sep 28 '22 14:09

Sean Patrick Floyd