从jacoco coverage报告中排除指定的包/类

时间:2017-12-29 06:24:29

标签: maven-plugin jacoco-maven-plugin

我正在开发基于Spring的Web应用程序。但是,我们正在使用scalatest进行单元测试。

我们正在使用jacoco maven插件来生成代码覆盖率报告。 现在我试图排除一些包来增加代码覆盖率。为此我完成了如下配置。但指定的包不会从报告中排除。你能帮我解决这个问题吗?

        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${maven-jacoco-plugin.version}</version>
            <inherited>false</inherited>
            <executions>
                <execution>
                    <id>jacoco-initialize</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>jacoco-site</id>
                    <phase>package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>

                    <configuration>
                        <excludes>
                            <exclude>**/model/*</exclude>
                        </excludes>
                    </configuration>
                </execution>
                <execution>
                    <id>default-check</id>
                    <goals>
                        <goal>check</goal>
                    </goals>
                    <configuration>
                        <rules>
                            <rule>
                                <element>BUNDLE</element>
                                <limits>
                                    <limit>
                                        <counter>LINE</counter>
                                        <value>COVEREDRATIO</value>
                                        <minimum>0.45</minimum>
                                    </limit>
                                </limits>
                            </rule>
                        </rules>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven-surefire-plugin.version}</version>
            <inherited>false</inherited>
            <configuration>

                <excludes>
                    <exclude>**/model/*</exclude>
                </excludes>
            </configuration>
        </plugin>

0 个答案:

没有答案