Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Description / Features

The plugin provides and imports a generic test coverage format. Regardless of language or combination of languages, if you get your coverage data into the generic format specified by this plugin, it will be imported and correctly applied.

Installation

  1. Install the plugin through the Update Center or download it into the SONARQUBE_HOME/extensions/plugins directory
  2. Restart the SonarQube server

Usage

Coverage report format

The project for which you want to import coverage data should contain an XML file complying with the attached XSD schema.
It should look like the following sample:

<coverage version="1">
<file path="src/main/java/com/example/MyClass.java">
<lineToCover lineNumber="2" covered="false"/>
<lineToCover lineNumber="3" covered="true" branchesToCover="8" coveredBranches="7"/>
</file>
</coverage>

The root node should be named "coverage". Its version attribute should be set to "1".
Insert a "file" element for each file which can be covered by tests. Its "path" attribute can be either absolute or relative to the root of the module.
Inside a "file" element, insert a "lineToCover" for each line which can be covered by unit tests. It can have the following attributes:

  • "lineNumber" (mandatory)
  • "covered" (mandatory): boolean value indicating whether tests actually hit that line
  • "branchesToCover" (optional): number of branches which can be covered
  • "coveredBranches" (optional): number of branches which are actually covered by tests

Project configuration

The path to the XML file containing coverage data can be configured in 2 ways:

  • In the SonarQube page of the project: Configuration > Settings > Generic Coverage.
  • By setting the sonar.genericcoverage.reportPath property

This path can be either absolute or relative to the root of the module.

Coverage data will be imported on the next analysis. If this is not the case, check the analysis logs for warnings.

 

  • No labels