JaCoCo Coverage Data Write Behavior | Generated by AI

Home 2025.10

In integration tests (or any JVM process) using the JaCoCo agent, the coverage data is not automatically written to the .exec file when the JVM exits. Here’s how it works:


When Does JaCoCo Write Coverage Data?


How to Ensure Data is Written

  1. Graceful Shutdown: Ensure your integration tests or application ends normally (e.g., no forced exits).
  2. Explicit Dump (Optional): You can manually trigger a dump of coverage data during runtime using the JaCoCo runtime API (e.g., org.jacoco.agent.rt.RT.getAgentRuntime().dump(true, outputFile)). This is useful for long-running processes or if you want to capture intermediate data.

Example Scenario


Best Practice



Back

openai/gpt-5

Donate