【问题标题】:Exclude files in Jacoco Coverage Report在 Jacoco 覆盖率报告中排除文件
【发布时间】:2019-04-10 09:47:15
【问题描述】:

我一直在尝试从生成的覆盖率报告中删除某些文件。我尝试了以下事情:

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.1</version>
            <executions>
                <execution>
                    <id>report-aggregate</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>report-aggregate</goal>
                    </goals>
                    <configuration>
                        <excludes>
                            <exclude>**/com/abc/def/**</exclude>
                        </excludes>
                    </configuration>
                </execution>
                <execution>
                    <id>check</id>
                    <goals>
                        <goal>check</goal>
                    </goals>
                    <configuration>
                        <rules>
                            <rule >
                                <element>BUNDLE</element>
                                    <limits>
                                        <limit >
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.50</minimum>
                                        </limit>
                                    </limits>
                            </rule>
                        </rules>
                    </configuration>
                </execution>
            </executions>
        </plugin>

修改代码:

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.9</version>
            <configuration>
                <excludes>
                    <exclude>**/com/abc/def/**</exclude>
                </excludes>
            </configuration>
            <executions>
                <execution>
                    <id>report-aggregate</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>report-aggregate</goal>
                    </goals>
                </execution>
                <execution>
                    <id>check</id>
                    <goals>
                        <goal>check</goal>
                    </goals>
                    <configuration>
                        <rules>
                            <rule >
                                <element>BUNDLE</element>
                                    <limits>
                                        <limit >
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.50</minimum>
                                        </limit>
                                    </limits>
                            </rule>
                        </rules>
                    </configuration>
                </execution>
            </executions>
        </plugin>

也试过了,

<configuration>
                        <rules>
                            <rule >
                                <element>BUNDLE</element>
                                    <limits>
                                        <limit >
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.50</minimum>
                                        </limit>
                                    </limits>
                                <excludes>
                                    <exclude>com.abc.def.className</exclude>
                                </excludes>
                            </rule>
                        </rules>
                    </configuration>

我在尝试找到解决方案时引用的许多链接中的一些:

Maven Jacoco Configuration - Exclude classes/packages from report not working

Jacoco how to correctly exclude package

How to add more Jacoco exclusions in a child project?

http://tdongsi.github.io/blog/2017/09/23/jacoco-in-maven-project/

但每次生成报告时,文件仍会显示在给定模块中。

【问题讨论】:

    标签: configuration code-coverage pom.xml jacoco jacoco-maven-plugin


    【解决方案1】:

    在被困了几个小时之后,这就是我所做的:

    <configuration>
         <excludes>
              <exclude>com/package/name/FileName*</exclude>
         </excludes>
    </configuration>
    

    在文件名之后添加 * 对我来说是关键部分。我曾多次尝试放置 FileName.java,但它仍然会包含它,我添加了 *

    【讨论】:

      猜你喜欢
      • 2015-08-24
      • 2018-07-27
      • 2018-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多