-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Description
The code coverage reported in SonarCloud for the project is 0%, despite having multiple tests implemented.
After investigating the pom.xml, we found that the issue is not the lack of tests, but a synchronization and configuration problem with JaCoCo and Surefire/Failsafe plugins. Specifically (at pom.xml):
- The
<argLine>parameter in bothmaven-surefire-pluginandmaven-failsafe-pluginis being manually overwritten (to configure Mockito and Java modules), which accidentally removes the JaCoCo agent from the JVM during test execution. - The
prepare-agentgoal for JaCoCo is not strictly bound to theinitializephase. - The XML report format is not explicitly configured, making it difficult for SonarCloud to read the data.
Because of this, the jacoco.exec file is not generated, resulting in 0% coverage.
Steps to Reproduce
- Clone the repository.
- Run the command
mvn clean verify. - Check the
targetfolder. Thejacoco.execfile is either missing or empty, and no validjacoco.xmlis generated for SonarCloud.
Expected behavior
When running mvn clean verify, JaCoCo should properly instrument the tests, generate the jacoco.exec binary, and format it into a jacoco.xml report. SonarCloud should then be able to read this file and display the real code coverage (which should be around 86%).
Environment
- OFT: [4.2.2]
- OS: [ Windows 11]
- Java Version: [openjdk version "25.0.2"]
- Maven Version: [3.9.12]
Additional context
We have already investigated and fixed this issue locally by injecting the ${jacoco.agent} property into the <argLine> and adjusting the pom.xml configuration. We will open a Pull Request shortly linking to this issue with the proposed solution.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status