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.
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
Before running SonarQube analysis, ensure you have:
- Java 17 or higher installed
- Maven installed (or use the included Maven wrapper
./mvnw) - SonarQube server running locally or remotely
- Default local URL:
http://localhost:9000
- Default local URL:
- SonarQube authentication token generated from your SonarQube instance
- Generate at: SonarQube → My Account → Security → Generate Tokens
- Enable the plugin for this SonarQube project by following the directions here
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_TOKENAfter the analysis completes:
- Open your SonarQube dashboard in a browser
- Navigate to the Spring-PetClinic-Demo project
- 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
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