Code coverage always 100% during pipeline execution | Community
Skip to main content
Level 2
March 5, 2026
Question

Code coverage always 100% during pipeline execution

  • March 5, 2026
  • 3 replies
  • 36 views

For all of the pipelines, production and non-production, the code coverage results always 100%, but this is impossible, because we haven’t all of coverage and in local with JaCoCo is less then cloud environments.

What could be the problem?

3 replies

AmitVishwakarma
Community Advisor
Community Advisor
March 5, 2026

Hi ​@g.davico ,

In Cloud Manager, coverage comes from JaCoCo -> SonarQube -> “Coverage” metric in the Code Quality step, not directly from your local JaCoCo HTML. If SonarQube sees no (or almost no) Java “lines to cover”, it reports 100% coverage by definition, and Cloud Manager just surfaces that value. This is documented behavior for projects without Java code: such projects report 100% coverage even though nothing is really being measured (https://experienceleague.adobe.com/en/docs/experience-manager-cloud-manager/content/release-notes/rn-2019/2019-12-0) and coverage definition in (https://experienceleague.adobe.com/en/docs/experience-manager-cloud-manager/content/using/code-quality-testing)

So if all your pipelines show 100% but local JaCoCo is lower, the problem is almost always:
Your real Java code isn’t in the coverage scope of the Cloud Manager SonarQube analysis.

 

Typical reasons:

  • The modules Cloud Manager actually analyzes have no Java code (only content/dispatcher/etc.).
  • A custom jacoco-maven-plugin config excludes or restricts your main code via includes / excludes.
  • A Cloud-Manager‑only Maven profile changes what’s built or how JaCoCo runs.

Quick checks:

Amit Vishwakarma - Adobe Commerce Champion 2025 | 16x Adobe certified | 4x Adobe SME
g.davicoAuthor
Level 2
March 6, 2026

Thanks for the detailed explanation! I followed all steps: downloaded Code Quality CSV (only shows issues, no coverage metrics like lines_to_cover/uncovered_lines), reproduced CM build locally (mvn clean verify org.jacoco:jacoco-maven-plugin:prepare-agent package), and confirmed realistic coverage <100% in core/target/site/jacoco/index.html (~81% LINE as per jacoco.xml).​

My Setup (Standard AEM Archetype)

  • Parent POM: No custom profiles (no cmBuild or env.CM_BUILD=true activation). Standard JaCoCo ${jacoco.version}=0.8.11 prop. Modules: allcoreui.frontendui.apps, etc.

  • Core POM (only Java module): JaCoCo plugin with:

     

    text

    <excludes> <exclude>**/package-info.java</exclude> <exclude>**/config/**</exclude> <!-- No business logic here --> <exclude>**/constants/**</exclude> <!-- No testable code --> <exclude>**/enums/**</exclude> <!-- Trivial --> </excludes>

    Executions: prepare-agentreport (phase=test), check (LINE>50%, BRANCH>30%). 373 tests pass locally.

Local CM command generates jacoco.exec → jacoco.xml → HTML report with 81% LINE coverage on actual classes (*.core.models.*, servlets, etc.). But pipeline stubbornly shows 100%.

What We've Ruled Out

  • No Java-less modules: Sonar analyzes CM-Sonar-Build/core/src/main/java/... (CSV has issues there).

  • No CM-specific profiles: Parent has only autoInstall* profiles (dev/deploy).

  • JaCoCo works: Local matches expected; excludes don't zero-out lines (XML shows missed lines).

  • CSVbuild_project_issues.csv = issues only, no coverage data → where's the real metrics CSV?

Why Still 100%?

SonarQube's Zero Coverage Sensor assigns 100% to "simple" classes (getters/setters) + formula (CT+CF+LC)/(2B+EL) inflates it? But local XML contradicts (81% real). Or CM skips report import despite logs saying "Importing 1 reports"?

Can Adobe confirm:

  1. Exact lines_to_cover/uncovered_lines for "core" module in pipeline?

  2. Does CM override excludes or skip JaCoCo for certain paths?

  3. Full coverage CSV (not just issues)?

Local XML proves tests aren't 100% - pipeline metric is misleading. Quality Gate passes anyway (>80% threshold), but need accurate reporting. Thoughts?

giuseppebaglio
Level 10
March 6, 2026

Hi ​@g.davico

The most likely root cause is that Cloud Manager is reporting 100% coverage because JaCoCo has no classes to measure, or is scanning only test files or already-excluded code. Here are the main reasons:

  • The JaCoCo agent (prepare-agent) is not running before the test phase, so no .exec file is generated with instrumentation data
  • The jacoco-maven-plugin is misconfigured and scans the wrong module (e.g., a module with no source classes, only test classes)
  • The target/classes directory is empty or excluded at scan time

Other Common Root Causes:

  • If your pom.xml has a <sonar.coverage.exclusions> or JaCoCo <excludes> pattern that inadvertently matches all production classes, the coverage shows as 100% (source)
  • If jacoco:prepare-agent doesn't run before Surefire executes tests, no instrumentation is injected, and JaCoCo has nothing to report — defaulting to 100%
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal> <!-- Must run BEFORE tests -->
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>

 

g.davicoAuthor
Level 2
March 6, 2026

Hi ​@giuseppebaglio,

this is my core pom jacoco configuration:

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<configuration>
<excludes>
<exclude>**/package-info.java</exclude>
<exclude>**/config/**</exclude>
<exclude>**/constants/**</exclude>
<exclude>**/enums/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check-coverage</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.50</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.30</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>

In the folder core\target\site\jacoco I have xml and html files with correct data and coverage, and I have also jacoco.exec file in core\target.

 

In the pipeline log I read
 

10:59:29,108 [main] [INFO] 10:59:29.108   Excluded sources for coverage: **/it/**/*.java, **/jcr_root/**/*.js

In the pipeline command I read:

Executing command mvn -Dmaven.build.cache.skipCache=true org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar -X -Dsonar.findbugs.allowuncompiledcode=true -Dsonar.projectKey=CM-Sonar-Build -Dsonar.host.url=http://localhost:9000 -Dsonar.coverage.exclusions=**/it/**/*.java,**/jcr_root/**/*.js -Dsonar.scm.disabled=true

But I cannot edit the command, and I’m not set the sonar.coverage.exclusions property.

Thanks