mcpField
J
jacoco

jacoco

github.com/claude-dev-suiteTesting & quality4652 installsUpdated 2d ago
Repository

About jacoco

A quick-reference skill for Java developers configuring JaCoCo coverage in Maven projects, including thresholds, reports, exclusions, and CI guidance.

Key features

  1. 01Maven coverage configuration
  2. 02Coverage thresholds
  3. 03Report generation
  4. 04Class exclusions
  5. 05Troubleshooting

Use cases

  1. 01Adding coverage checks to a Maven build
  2. 02Reviewing line and branch coverage
  3. 03Investigating missing coverage reports

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill jacoco

After installing, type/jacocoin Claude Code to confirm it loaded.

Details

From the project README

JaCoCo - Quick Reference

When to Use This Skill

  • Configure code coverage in Java/Maven projects
  • Set coverage thresholds
  • Integrate coverage in CI/CD

When NOT to Use This Skill

  • JavaScript/TypeScript coverage - Use Vitest skill for frontend coverage
  • SonarQube configuration - Use sonarqube skill for quality gates
  • Test writing - Use Spring Boot Test or JUnit skills
  • Gradle projects - JaCoCo works but syntax differs from Maven

Deep Knowledge: Use mcp__documentation__fetch_docs with technology: jacoco for comprehensive documentation.

Essential Patterns

Maven Configuration
<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>test</phase>
            <goals><goal>report</goal></goals>
        </execution>
        <execution>
            <id>check</id>
            <goals><goal>check</goal></goals>
            <configuration>
                <rules>
                    <rule>
                        <element>BUNDLE</element>
                        <limits>
                            <limit>
                                <counter>LINE</counter>
                                <value>COVEREDRATIO</value>
                                <minimum>0.80</minimum>
                            </limit>
                        </limits>
                    </rule>
                </rules>
            </configuration>
        </execution>
    </executions>
</plugin>
Exclusions
<excludes>
    <exclude>com.company.config.*</exclude>
    <exclude>com.company.dto.*</exclude>
    <exclude>com.company.entity.*</exclude>
    <exclude>com.company.mapper.*Impl</exclude>
</excludes>
Commands
mvn clean verify           # Test + coverage check
mvn jacoco:report          # Generate report
open target/site/jacoco/index.html  # View report

Counter Types

CounterDescription
LINELines of code
BRANCHBranch if/switch
METHODMethods

Anti-Patterns

Anti-PatternWhy It's BadCorrect Approach
Aiming for 100% coverageDiminishing returns, test bloatTarget 80% LINE, 70% BRANCH
Including DTOs/entities in coverageInflates numbers, no logic to testExclude with <excludes>
Only checking LINE coverageMisses untested branchesCheck both LINE and BRANCH
No coverage threshold in CICan't enforce qualityAdd <check> goal with minimums
Excluding too much codeFalse sense of securityOnly exclude generated/config code
Not versioning jacoco.execCan't track coverage trendsArchive reports in CI

Quick Troubleshooting

IssueLikely CauseSolution
Coverage report shows 0%Tests not running with agentEnsure prepare-agent goal runs before tests
Build fails on coverage checkCoverage below thresholdAdd tests or adjust minimum in <limit>
Report excludes nothingWrong exclude patternUse fully qualified names (com.company.dto.*)
Report missing classesClasses not loaded during testsAdd integration tests to cover them
Coverage lower in CI than localDifferent test executionEnsure CI runs all test phases
SonarQube shows no coverageWrong report pathCheck sonar.coverage.jacoco.xmlReportPaths

Further Reading

For advanced configurations: mcp__documentation__fetch_docs

  • Technology: jacoco (not yet in MCP - use official docs)
  • JaCoCo Docs

Comments

Markdown supported