Skip to content

0% Code Coverage in SonarCloud (JaCoCo agent not instrumenting tests) #494

@GloriaCP

Description

@GloriaCP

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):

  1. The <argLine> parameter in both maven-surefire-plugin and maven-failsafe-plugin is being manually overwritten (to configure Mockito and Java modules), which accidentally removes the JaCoCo agent from the JVM during test execution.
  2. The prepare-agent goal for JaCoCo is not strictly bound to the initialize phase.
  3. 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

  1. Clone the repository.
  2. Run the command mvn clean verify.
  3. Check the target folder. The jacoco.exec file is either missing or empty, and no valid jacoco.xml is 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

📫 Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions