【问题标题】:Ignore Classes and Methods form Code Coverage (jacoco)忽略类和方法形成代码覆盖 (jacoco)
【发布时间】:2018-02-10 01:26:13
【问题描述】:

在我的应用程序中,我想忽略类(packageName1/Starter/packageName1/IO/CmdException.class) 以及每个类 equalshashCode 方法。

我的pom.xml 看起来像:

<build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.0.201403182114</version>
                <configuration>
                    <instrumentation>
                        <ignores>
                            <ignore>*hashCode</ignore>
                             <ignore>*equals</ignore>
                        </ignores>
                        <excludes>
                            <exclude>packageName1/Starter.class</exclude>
                            <exclude>packageName1/IO/CmdException.class</exclude>
                        </excludes>
                    </instrumentation>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

问题是覆盖仍然威胁着这些类和方法。

【问题讨论】:

  • 嗨,你找到方法了吗?

标签: java code-coverage jacoco jacoco-maven-plugin


【解决方案1】:

这对我来说可以排除类。

<plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.8</version>

                <configuration>

                    <ignores>
                        <ignore>com.sample.package.bean.*</ignore>

                    </ignores>
                    <excludes>
                        <!-- all class which we want to exclude from the coverage report -->
                        <exclude>**/*class1.class</exclude>
                        <exclude>**/*class2.class</exclude>
                        <exclude>**/*class3.class</exclude>
                        <exclude>**/*class4.class</exclude>





                    </excludes>



                </configuration>


                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-29
    • 2012-06-11
    • 1970-01-01
    • 1970-01-01
    • 2014-11-09
    • 2016-11-11
    • 2019-01-02
    • 2012-11-02
    相关资源
    最近更新 更多