Fügen Sie pom Folgendes hinzu, indem Sie auf den Inhalt der offiziellen Website verweisen (www.jacoco.org).
pom.xml
<project>
	<build>
        <pluginManagement>
            <plugins>
               <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>***</version>
                    <executions>
                        <execution>
                            <id>default-prepare-agent</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>default-report</id>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>default-check</id>
                            <goals>
                                <goal>check</goal>
                            </goals>
                            <configuration>
                                <rules>
                                    <!--  implementation is needed only for Maven 2  -->
                                    <rule implementation="org.jacoco.maven.RuleConfiguration">
                                        <element>BUNDLE</element>
                                        <limits>
                                            <!--  implementation is needed only for Maven 2  -->
                                            <limit implementation="org.jacoco.report.check.Limit">
                                                <counter>COMPLEXITY</counter>
                                                <value>COVEREDRATIO</value>
                                                <minimum>0.60</minimum>
                                            </limit>
                                        </limits>
                                    </rule>
                                </rules>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
Wenn Sie Folgendes in maven ausführen, wird ein Bericht in target / site / jacoco / index.html generiert.
mvn clean jacoco:prepare-agent test jacoco:report
(Klicken Sie in NetBeans mit der rechten Maustaste auf das Projekt-> Run Maven-> Ziel.)
Recommended Posts