Skip to content

diffblue/Diffblue-SonarQube-Example-Repo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Diffblue SonarQube Plugin - Example Repository

This is a modified version of spring-petclinic to enable free and easy testing of the Diffblue SonarQube Plugin, which integrates coverage data about Diffblue's AI-generated tests into SonarQube. This repository contains tests generated by Diffblue Cover as well as the necessary metadata to use the Diffblue SonarQube Plugin for this project.

About this project

This is a Spring Boot 3.1.3 application using Java 17 that includes:

  • Sample application code
  • Diffblue Cover-generated unit tests (located in src/test/java/)
  • Maven build configuration with SonarQube integration
  • Pre-generated Diffblue coverage metadata (located in .diffblue/reports) for testing the Diffblue SonarQube Plugin

Prerequisites

Before running SonarQube analysis, ensure you have:

  1. Java 17 or higher installed
  2. Maven installed (or use the included Maven wrapper ./mvnw)
  3. SonarQube server running locally or remotely
    • Default local URL: http://localhost:9000
  4. SonarQube authentication token generated from your SonarQube instance
    • Generate at: SonarQube → My Account → Security → Generate Tokens
  5. Enable the plugin for this SonarQube project by following the directions here

Running SonarQube analysis with the Diffblue SonarQube Plugin

Once you have the Diffblue SonarQube Plugin installed in your SonarQube instance and enabled for this project, analyze this project by running:

mvn clean verify sonar:sonar \
  -Dsonar.projectKey=Spring-PetClinic-Demo \
  -Dsonar.projectName='Spring-PetClinic-Demo' \
  -Dsonar.host.url=http://localhost:9000 \
  -Dsonar.token=YOUR_SONARQUBE_TOKEN

Viewing the results

After the analysis completes:

  1. Open your SonarQube dashboard in a browser
  2. Navigate to the Spring-PetClinic-Demo project
  3. Review the Diffblue section in the Measures tab. Here, you'll find:
    • Coverable Lines: the total number of lines that could be covered by unit tests, according to JaCoCo
    • Lines Covered by Diffblue (total): the total number of lines covered by Diffblue tests
    • Lines Covered by Diffblue (exclusively): the total number of lines covered only by Diffblue tests
    • Coverage from Diffblue (total): the percentage of coverable lines covered by Diffblue tests
    • Coverage from Diffblue (exclusively): the percentage of coverable lines covered only by Diffblue tests

Troubleshooting

Authentication Failed: Verify your token is correct and has analysis permissions

Connection Refused: Ensure SonarQube is running and the URL is correct

Build Failures: Run mvn clean install first to verify the project builds successfully

Additional Resources

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors