Installation and Usage
This page describes how to install, configure, and use the Diffblue SonarQube Plugin.
Prerequisites
To use the Diffblue SonarQube Plugin, you will need:
A Java project that contains tests written by Diffblue Cover
Diffblue Cover CLI
A SonarQube Server or SonarQube Community Edition instance
Java 17+ installed where you run SonarQube analysis
Installation
Download
Diffblue SonarQube Plugin releases are published on GitHub: https://github.com/diffblue/diffblue-sonar-plugin/releases. Download the diffblue-sonar-plugin-X.X.X.jar file.
Install
The Diffblue SonarQube Plugin can be installed on SonarQube Server or SonarQube Community Edition by following the instructions provided by SonarQube:
https://docs.sonarsource.com/sonarqube-server/server-installation/plugins/install-a-plugin
https://docs.sonarsource.com/sonarqube-community-build/server-installation/plugins/install-a-plugin
Third-party plugins cannot be installed on SonarQube Cloud.
Configuration
The Diffblue SonarQube Plugin is configurable per project. It is disabled by default.
For each project that should calculate Diffblue metrics:
Open the project in the SonarQube UI.
Navigate to Project Settings > General Settings.
Go to the Diffblue section.
Toggle the plugin on or off for this project. Save your changes and they will take effect on the next run.
Usage Patterns
The plugin will calculate and store Diffblue metrics for each module in a project if:
The Diffblue plugin is enabled for that project;
The module contains Java source code; and
The required JaCoCo XML input files are present.
Therefore, when SonarQube analysis runs, the required JaCoCo XML input files (.diffblue/reports/diffblue-tests-jacoco-report.xml and .diffblue/reports/manual-tests-jacoco-report.xml, which are produced by Diffblue Cover’s dcover coverage-reports command) need to be available to be processed. This can be done in several ways to match your preferences and the way you use Cover to generate tests.
Option 1 – Local Test Generation
Developers generate Diffblue tests locally and commit them to the repository. CI pipelines then run dcover coverage-reports to generate the coverage data files before SonarQube analysis occurs. No JaCoCo XML files need to be committed to the repository.
Option 2 – Commit Reports
Teams generate Diffblue tests and run dcover coverage-reports locally, committing the tests as well as both of the Diffblue-generated JaCoCo report files to the repository. When SonarQube analysis runs in CI, the required input files are present in the repository and are processed by the Diffblue SonarQube plugin.
Option 3 – Fully in CI
The CI pipeline runs both dcover create and dcover coverage-reports to create Diffblue tests and measure coverage of Diffblue and manual tests. These steps need to occur in the pipeline prior to SonarQube analysis so that the JaCoCo XML files are present when the Diffblue SonarQube Plugin runs. The JaCoCo XML files do not need to be committed to the repository.
Last updated
Was this helpful?

