Test coverage parameters
Test coverage reports describe the percentage of your code that has been tested by your test suite during a build.
This differs from test execution reports, which describe which tests within your test suite have been run during a build. For details, see test execution parameters.
Test coverage reports are not generated by SonarQube Server itself. They must be generated by an external tool and then imported into SonarQube Server by specifying a parameter telling the scanner where to look for the report. The data is then displayed in your SonarQube Server analysis.
Below, you will find language- and tool-specific analysis parameters for importing test coverage reports.
For information on analysis parameters in general, see analysis parameters.
Unless otherwise specified, these properties require values that are relative to the project root. Some properties support the following wildcards in paths. The remarks for properties that support wildcards will mention this fact. If wildcards are not noted for a given property, then they are not supported for that property.
Symbol | Meaning |
? | a single character |
* | any number of characters |
** | any number of directories |
All languages
sonar.coverageReportPaths
- Comma-delimited list of paths to coverage reports in the generic test data format.
Apex
sonar.apex.coverage.reportPath
- Path to the
test-result-codecoverage.json
report file generated by theapex:test:run
command of the Salesforce CLI. Note, you must have a Salesforce DX project set up and linked to your organization.
C/C++/Objective-C
See C/C++/Objective-C test coverage for examples and details.
sonar.cfamily.gcov.reportsPath
- Path to the directory containing native
*.gcov
reports (not the XML reports generated bygcovr
).
sonar.cfamily.llvm-cov.reportPath
- Path to the
llvm-cov
report.
sonar.cfamily.vscoveragexml.reportsPath
- Path to the Visual Studio Code Coverage report. The path may be absolute or relative to the solution directory. Path wildcards (see above) are supported. Note that the
.coverage
report format must be converted to.coveragexml
format using the toolCodeCoverage.exe
tool in order to be imported.
sonar.cfamily.bullseye.reportPath
- Path to the report from Bullseye, version >= 8.9.63 (use the
covxml
tool)
C#
See .NET test coverage for examples and details.
sonar.cs.vscoveragexml.reportsPaths
- Comma-delimited list of paths to the coverage reports produced by Visual Studio Code Coverage or the
dotnet-coverage
tool. Wildcards are supported.
sonar.cs.dotcover.reportsPaths
- Comma-delimited list of paths to the dotCover coverage reports.
sonar.cs.opencover.reportsPaths
- Comma-delimited list of paths to the OpenCover or Coverlet coverage reports.
Dart
See Dart test coverage for examples and details.
sonar.dart.lcov.reportPaths
- Comma-delimited list of paths to LCOV reports. Wildcards are supported. Paths may be absolute or relative to the project root.
- To produce this format, you need to activate coverage and run tests with it. If no path is provided, or no report coverage report is found at the provided paths, the default location is used:
coverage/lcov.info
.
Flex
sonar.flex.cobertura.reportPaths
- Path to the Cobertura XML reports. Multiple paths may be comma-delimited. May be absolute or relative to the project base directory.
Go
sonar.go.coverage.reportPaths
- Comma-delimited list of paths to coverage report files. Wildcards are supported.
Java/Kotlin/Scala/JVM
See Java test coverage for examples and details.
sonar.coverage.jacoco.xmlReportPaths
- Comma-delimited list of paths to JaCoCo XML coverage reports. Wildcards are supported.
sonar.jacoco.reportPaths
- Deprecated. Use
sonar.coverage.jacoco.xmlReportPaths
instead.
JavaScript/TypeScript
See JavaScript/TypeScript test coverage for examples and details.
sonar.javascript.lcov.reportPaths
- Comma-delimited list of paths to LCOV coverage report files. Paths may be absolute or relative to the project root.
PHP
See PHP test coverage for examples and details.
sonar.php.coverage.reportPaths
- Comma-delimited list of paths to Clover XML-format coverage report files. Paths may be absolute or relative to the project root.
Python
See Python test coverage for examples and details.
sonar.python.coverage.reportPaths
- Comma-delimited list of paths to coverage reports in the Cobertura XML format. Wildcards are supported. Leave unset to use the default,
coverage-reports/*coverage-*.xml
.
Ruby
sonar.ruby.coverage.reportPaths
- Comma-delimited list of paths to SimpleCov report files generated with the JSON formatter (available from SimpleCov 0.20). For SimpleCov versions before 0.18, you can provide
.resultset.json
report files (though we recommend updating to 0.20 and using the JSON formatter). Paths may be absolute or relative to the project root. - When using the
simplecov_json_formatter
from simplecov >= v0.20, add
-D sonar.ruby.coverage.reportPaths=coverage/coverage.json \
to your SonarScanner code.
Scala
sonar.scala.coverage.reportPaths
- Comma-delimited list of paths to
scoverage.xml
report files generated by Scoverage.
Swift with Xcode 13.3+
You can use the xccov-to-sonarqube-generic.sh script from the sonar-scanning-examples/swift-coverage project to convert output from Xcode 13.3's xccov
tool to the Generic test data format.
See this community guide for help with importing your coverage or test data.
Swift with Xcode 7-13.2
sonar.swift.coverage.reportPaths
- Comma-delimited list of paths to the report files generated by
llvm-cov show
. A path may be absolute or relative to the project root.
VB.NET
See .NET test coverage for examples and details.
sonar.vbnet.vscoveragexml.reportsPaths
- Comma-delimited list of paths to Visual Studio Code Coverage reports. Wildcards are supported.
sonar.vbnet.dotcover.reportsPaths
- Comma-delimited list of paths to dotCover coverage reports.
sonar.vbnet.opencover.reportsPaths
- Comma-delimited list of paths to OpenCover coverage reports.
Was this page helpful?