Complete the code to generate a coverage report using JaCoCo in a Maven project.
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.8</version> <executions> <execution> <goals> <goal>[1]</goal> </goals> </execution> </executions> </plugin>
The prepare-agent goal sets up the JaCoCo agent to collect coverage data during tests.
Complete the code to generate the coverage report after tests run.
<execution>
<id>report</id>
<phase>[1]</phase>
<goals>
<goal>report</goal>
</goals>
</execution>The verify phase runs after tests and is the right time to generate the coverage report.
Fix the error in the JaCoCo plugin configuration to correctly bind the report goal.
<execution>
<id>default-report</id>
<phase>[1]</phase>
<goals>
<goal>report</goal>
</goals>
</execution>The verify phase is the correct lifecycle phase to bind the report goal for coverage reports.
Fill both blanks to create a JaCoCo report that includes XML and HTML formats.
<configuration>
<formats>
<format>[1]</format>
<format>[2]</format>
</formats>
</configuration>JaCoCo supports xml and html formats for coverage reports.
Fill all three blanks to configure JaCoCo to fail the build if coverage is below 80%.
<configuration>
<rules>
<rule>
<element>[1]</element>
<limits>
<limit>
<counter>[2]</counter>
<value>[3]</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>The element is set to CLASS to check coverage per class, the counter is LINE to measure line coverage, and the value is COVEREDRATIO to specify the coverage ratio metric.
This configuration ensures the build fails if line coverage is below 80%.