JaCoCo Runtime Execution File Behavior | Generated by AI
When you run WebSphere Liberty Profile with the JaCoCo agent in exec mode, the JaCoCo agent does not modify the original .exec file during runtime. Here’s what happens:
How JaCoCo Works in exec Mode
- Purpose: The JaCoCo agent collects code coverage data while your application runs.
- Output: It writes coverage data to the
.execfile (e.g.,jacoco.exec). - File Behavior:
- If the file does not exist, JaCoCo creates it.
- If the file already exists, JaCoCo appends new coverage data to it (it does not overwrite or modify existing data unless you explicitly reset or merge the file).
- The original
.execfile is not altered in a way that would break or change its structure—it only grows with new data.
Will the .exec File Be Modified?
- Yes, but only by appending data: The file will be updated with new coverage information each time you run your application with the JaCoCo agent.
- No structural changes: The format of the
.execfile remains the same; it’s a binary file containing coverage data.
Best Practices
- Merge or Reset: If you want to start fresh, delete or rename the
.execfile before running your application again. - Merge Multiple Runs: Use the
jacoco:mergegoal (in Maven) or theorg.jacoco.agent.rt.RTclass to merge multiple.execfiles if needed.
Example Liberty Configuration
In your server.env or jvm.options for Liberty, you might see:
-javaagent:/path/to/jacocoagent.jar=destfile=/path/to/jacoco.exec,append=true
append=trueensures new data is added to the existing file.