Help us understand the problem. What is going on with this article?

【JaCoCo(Java Code Coverage)】NetBeansでの使用

More than 1 year has passed since last update.

ライブラリの読み込み

公式サイト(www.jacoco.org)の内容を参考にpomに下記を追記

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>

使い方

mavenで下記を実行すると、target/site/jacoco/index.htmlにレポートが生成されます。

mvn clean jacoco:prepare-agent test jacoco:report

(NetBeansでは、[プロジェクトを右クリック]→[Mavenを実行]→[ゴール])

zb185423
デジタル&アナログのものづくりを好むエンジニアです。 --- Scala/ Java JavaScript/ HTML/ CSS FORTRAN GIMP/ Inkscape 二級建築士/ 宅地建物取引士
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away