Skip to content

Enable test coverage reporting via JaCoCo #316

Description

@ntung

Summary

The project has no test coverage reporting configured. Adding JaCoCo would enable per-module HTML reports and lay the groundwork for CI coverage tracking.

Current State

  • core/pom.xml configures only maven-surefire-plugin (v2.19.1) with no coverage plugin
  • Root pom.xml has no coverage plugin in <build><plugins>
  • The surefire argLine is hardcoded (-Dfile.encoding=UTF-8 -ea), which prevents JaCoCo from injecting its agent via the ${argLine} property

Proposed Fix

1. Fix surefire's argLine in core/pom.xml to allow late evaluation by JaCoCo:

<!-- before -->
<argLine>-Dfile.encoding=UTF-8 -ea</argLine>

<!-- after -->
<argLine>@{argLine} -Dfile.encoding=UTF-8 -ea</argLine>

The @{argLine} form (vs ${argLine}) is required with JaCoCo ≥ 0.7.5 when both surefire and jacoco participate in the same build — it defers evaluation until after JaCoCo sets the property.

2. Add JaCoCo plugin to the root pom.xml (or core/pom.xml for core-only coverage):

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.12</version>
  <executions>
    <execution>
      <id>prepare-agent</id>
      <goals><goal>prepare-agent</goal></goals>
    </execution>
    <execution>
      <id>report</id>
      <phase>verify</phase>
      <goals><goal>report</goal></goals>
    </execution>
  </executions>
</plugin>

Usage After Fix

mvn -f core/pom.xml clean verify
# Report: core/target/site/jacoco/index.html

Notes

  • The core test suite runs through a Tests.java JUnit 4 suite class (configured via surefire <includes>). JaCoCo instruments at the bytecode level, so the suite class requires no changes.
  • Adding JaCoCo to the root pom.xml would also enable aggregate reports across all submodules (mvn jacoco:report-aggregate).

Metadata

Metadata

Assignees

No one assigned

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions