Skip to content

diffblue/diffblue-sonar-plugin

Diffblue SonarQube Plugin

The Diffblue SonarQube Plugin visualizes the test coverage provided by Diffblue Cover’s AI‑generated unit tests directly inside SonarQube. This allows development teams to view and track Diffblue‑specific testing metrics alongside their standard code quality measures — bringing AI‑powered testing insights into the familiar SonarQube dashboard.

What it provides

The plugin adds a set of coverage metrics that highlights the contribution of Diffblue Cover’s automatically generated tests. These measures help teams understand how much of their codebase is covered by AI‑written tests and where gaps remain.

Key measures include:

  • Diffblue Total Coverage (lines and %) – Lines covered by Diffblue‑generated tests, reported as both a line count and a percentage of executable lines.
  • Diffblue‑only Coverage (lines and %) – Lines that are covered exclusively by Diffblue‑generated tests (i.e., not covered by any other tests), also shown as a count and a percentage.

By integrating these metrics with SonarQube’s existing dashboards and quality gates, the plugin helps teams understand the specific contribution of Diffblue’s AI‑generated tests to their overall code coverage and code quality.

Prerequisites

  • SonarQube Community Edition (or compatible higher edition)
  • Java projects using Diffblue Cover. (Example repo with the necessary Diffblue data generated https://github.com/diffblue/SonarQube-Example-Repo)
  • Diffblue Cover CLI installed (Optional. Only needed for generating Diffblue tests and data on projects)

Installing the plugin on the SonarQube Server

  1. Obtain the Diffblue Cover SonarQube plugin JAR from the SonarQube marketplace, or build the SonarQube plugin jar file: mvn clean package
  2. Copy the produced sonar-plugin/target/diffblue-sonar-plugin-X.X.X.jar to the extensions/plugins/ directory of your SonarQube installation, replacing any previous versions. For example: cp sonar-plugin/target/diffblue-sonar-plugin-0.1.0-SNAPSHOT.jar ~/sonarqube-25.11.0.114957/extensions/plugins/
  3. Restart the SonarQube Server so that the new plugin is loaded and available to all projects.

Enabling the plugin for projects

Once the plugin is installed, project owners can enable and configure it per application.

The Diffblue Plugin is configurable at the Project-level. For each project that should use Diffblue metrics:

  1. Open the project in the SonarQube UI.
  2. Navigate to Project Settings → General Settings.
  3. Locate the Diffblue tab; configuration options will appear there.
  4. Within this tab you can:
  • Turn the plugin on for that project. (Off by default)

CI/CD integration patterns

The plugin supports both local development and automated CI/CD workflows.

Analysis are typically triggered on your build server or during local builds — the approach depends on how you manage source code and testing. A common pattern looks like this:

  1. Checkout source code.
  2. Build and test the project using Maven or Gradle.
  3. Run Diffblue Cover to generate tests and coverage reports.
  4. Run your SonarQube analysis (for example with mvn sonar:sonar or sonar-scanner).

Additionally, to enable coverage highlighting in SonarQube, you need to configure your build so that the JaCoCo XML generated by Diffblue cover (diffblue-tests-jacoco-report.xml and manual-tests-jacoco-report.xml) are passed to SonarQube as coverage inputs. You can do this by adding the appropriate sonar.coverage.jacoco.xmlReportPaths property in your Maven or Gradle configuration (or by supplying it as a system property on the command line).

For Maven

<properties>
    <sonar.coverage.jacoco.xmlReportPaths>
        .diffblue/reports/diffblue-tests-jacoco-report.xml,
        .diffblue/reports/manual-tests-jacoco-report.xml
    </sonar.coverage.jacoco.xmlReportPaths>
</properties>

For Gradle

sonarqube {
    properties {
        property "sonar.coverage.jacoco.xmlReportPaths",
                 ".diffblue/reports/diffblue-tests-jacoco-report.xml," +
                 ".diffblue/reports/manual-tests-jacoco-report.xml"
    }
}

Common Integration Options

Option 1 – Local Test Generation

Developers generate Diffblue tests locally (for example during development or refactoring).
CI pipelines then run dcover coverage-reports to generate existing coverage data — no Diffblue report files need to be committed.

Option 2 – Committed Reports

Teams locally generate Diffblue tests and commit the tests the accompanying coverage report files (such as diffblue-tests-jacoco-report.xml & manual-tests-jacoco-report.xml) into the repository.
This ensures consistent metrics across local and CI/CD builds.

Option 3 – Full CI Generation

The build pipeline runs both dcover create and dcover coverage-reports, generating and analyzing Diffblue tests automatically to ensure coverage metrics always match the current code.

About

Diffblue SonarQube plugin

Resources

License

Apache-2.0 and 2 other licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
license-java.txt
Unknown
license-pom.txt

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages