Collecting code coverage information for Android tests

The Android-specific test suites are outlined on MDN. A more elaborate description can be found on the Wiki. This page describes how collecting code coverage information is implemented for these test suites.

Collecting and exporting code coverage information

Relevant tools and libraries

grcov is a tool implemented in Rust that transforms code coverage reports between formats. Among others, it supports reading JaCoCo XML reports.

Generating the coverage report artifacts

All tasks that output code coverage information do so by exporting an artifact named code-coverage-grcov.zip which contains a single file named grcov_lcov_output.info. The grcov_lcov_output.info file should contain coverage information in the lcov format. The artifact, once uploaded, is picked up and indexed by ActiveData.

The code that generates the code-coverage-grcov.zip artifact after a generally resides in the CodeCoverageMixin class, in the module testing/mozharness/mozharness/mozilla/testing/codecoverage.py. This class is responsible for downloading grcov along with other artifacts from the build job. It is also responsible for running grcov after the tests are finished, to convert and merge the coverage reports.