Skip to content

Generating coverage reports

Code coverage is a metric used to describe the degree to which the source code of a program is tested. A program with high code coverage has been more thoroughly tested and has a lower chance of containing software bugs than a program with low code coverage. You can read more about the basics of code coverage on our blog.

There are many tools that you can use to generate coverage reports for the languages used in your repositories. The following table contains example coverage tools that generate reports in formats that Codacy supports:

Language Example coverage tools Report formats
C# OpenCover
dotCover CLI
OpenCover
dotCover XML
Java JaCoCo
Cobertura
JaCoCo
Cobertura
JavaScript Istanbul
Poncho
Mocha + Blanket.js
LCOV
PHP PHPUnit PHPUnit XML (version <= 4)
Clover
Python Coverage.py Cobertura
Ruby SimpleCov Cobertura
LCOV
Scala sbt-jacoco
scoverage
JaCoCo
Cobertura
Swift/Objective-C Xcode Code Coverage See below how to generate coverage reports with Xcode

Swift and Objective-C support

To use Swift and Objective-C with Xcode coverage reports, use Slather to convert the Xcode output into the Cobertura format.

To do this, execute the following commands on the CI:

gem install slather
slather coverage -x --output-directory <report-output-dir> --scheme <project-name> <project-name>.xcodeproj

This will generate a file cobertura.xml inside the folder <report-output-dir>.

After this, run Codacy Coverage Reporter to upload the coverage results to Codacy.

Last update: September 9, 2020