# Code Coverage Setup and Report Generation

Follow these steps to set up and view the code coverage report for your application:

1. Navigate to the root directory of your application
2. Download the JaCoCo library and extract it:
   1. Using Browser ([Link](https://www.jacoco.org/jacoco/trunk/index.html))&#x20;
   2. or Using Terminal
      1. For Linux OS
      2. For Windows OS

```
curl -L -o jacoco-0.8.12.zip https://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.8.12/jacoco-0.8.12.zip
unzip jacoco-0.8.12.zip -d jacoco-0.8.12
mkdir jars
mv jacoco-0.8.12/lib/* jars
```

```
curl -L -o jacoco-0.8.12.zip https://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.8.12/jacoco-0.8.12.zip
tar -xf jacoco-0.8.12.zip -C jacoco-0.8.12
mkdir jars
move jacoco-0.8.12\lib\* jars
```

3. Update `.htTestConf.js` 's `appStartCommandArgs`

```json
appStartCommandArgs: [
"-Dspring-boot.run.jvmArguments=-javaagent:jars/jacocoagent.jar=output=file,destfile=./coverage.exec",
"spring-boot:run"]
```

4. Execute the application in Replay mode
5. Generate and view coverage report

```
java -jar jars/jacococli.jar report ./coverage.exec \
    --classfiles target/classes \
    --sourcefiles src/main/java \
    --html report
```

6. To view the code coverage results, open the following `report/index.html` file.


---

# Agent Instructions: 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:

```
GET https://docs-v2.hypertest.co/user-guides/java-sdk/code-coverage-setup-and-report-generation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
