What does the JaCoCo agent collect during test execution?
JaCoCo focuses on code coverage, not performance metrics.
JaCoCo collects execution data to determine which parts of the code were run during tests, enabling coverage reports.
Given this Maven plugin snippet for JaCoCo, what is the expected output after running mvn test?
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>Check the plugin executions and phases.
The prepare-agent goal sets up the agent before tests, and the report goal runs in the test phase to generate the coverage report.
Which Gradle configuration snippet correctly fails the build if line coverage is below 80%?
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.80
}
}
}
}Look for the correct counter, value, and minimum threshold.
Option A correctly sets the counter to 'LINE', value to 'COVERED_RATIO', and minimum to 0.80, which means the build fails if coverage is below 80%.
After running tests with JaCoCo agent enabled, the coverage report shows 0% coverage. What is the most likely cause?
Think about how JaCoCo collects coverage data.
If the agent is not attached, no execution data is collected, resulting in zero coverage in reports.
In a CI pipeline using Jenkins, which step is essential to ensure JaCoCo coverage reports are archived and visible after the build?
Think about how Jenkins handles build artifacts and reports.
Archiving the JaCoCo report directory and publishing HTML reports in Jenkins allows developers to view coverage results directly in the CI interface.