> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/troubleshooting-faq/maven/jacoco-offline-instrumentation-no-coverage.md).

# JaCoCo Offline Instrumentation: No Coverage

### Problem: When working with both JaCoCo & Sealights, no coverage is captured for our Tests <a href="#problem-when-working-with-both-jacoco-and-sealights-no-coverage-is-captured-for-our-tests" id="problem-when-working-with-both-jacoco-and-sealights-no-coverage-is-captured-for-our-tests"></a>

JaCoCo has two way’s of instrumenting the code for capturing coverage:

1. In memory - JaCoCo is added as a javaagent and performs the instrumentation in memory when the JVM comes up in Surefire
2. Offline - JaCoCo instruments the physical files saved on the disk which get used by the JVM run by surefire

As the second option physically changes the code, it creates a situation where what Sealights originally scanned, and what Sealights receives from the coverage do not match, and therefore no coverage it calculated

In order to capture coverage from JaCoCo for Unit Tests, there is no need to use the Offline option, and it is sometimes used by mistake instead of the In memory option.

### Solution <a href="#solution" id="solution"></a>

Change you maven JaCoCo configuration to use the `prepare-agent` goal instead of the instrument & `restore-instrumented-classes` goals

For example:

{% code overflow="wrap" lineNumbers="true" %}

```
<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.9-SNAPSHOT</version>
  <executions>
    <execution>
      <id>default-prepare-agent</id>
      <goals>
        <goal>prepare-agent</goal>
      </goals>
    </execution>
    ...
```

{% endcode %}

Instead of:

{% code overflow="wrap" lineNumbers="true" %}

```
<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.9-SNAPSHOT</version>
  <executions>
    <execution>
    <id>default-instrument</id>
    <goals>
      <goal>instrument</goal>
    </goals>
  </execution>
  <execution>
    <id>default-restore-instrumented-classes</id>
    <goals>
      <goal>restore-instrumented-classes</goal>
    </goals>
  </execution>
  ...
```

{% endcode %}

### Related articles <a href="#related-articles" id="related-articles"></a>

* [Setting up a windows service](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/.net-core-agent/capturing-coverage-from-the-application/ms-windows-specific-configurations/setting-up-a-windows-service.md) (.Net Core)
* [Setting up IIS Listener](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/.net-core-agent/capturing-coverage-from-the-application/ms-windows-specific-configurations/setting-up-iis-listener.md) (.Net Core)
* [Cloud Foundry Integration](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/python-agent/capturing-coverage-from-runtime-application/cloud-foundry-integration.md) (Python)
* [NodeJS - JavaScript heap out of memory](/knowledgebase/setup-and-configuration/troubleshooting-faq/node-javascript/nodejs-javascript-heap-out-of-memory.md)
* [Running Your Backend Server with  SeaLights](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/python-agent/capturing-coverage-from-runtime-application/running-backend-server-using-sealights-agent.md) (Python)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/troubleshooting-faq/maven/jacoco-offline-instrumentation-no-coverage.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
