Maven PIT测试和Jacoco产品线覆盖率差异

时间:2018-10-13 23:50:45

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

我有一个正在使用Apache Maven的Java项目。我是Maven的新手。我需要澄清一下,在搜索的最后几个小时里找不到答案。

我有两个问题: 问题1)当我输入命令mvn clean install来构建我的项目时,它经历了所有步骤,并且确实完成了。构建失败,并说只有79%的线路覆盖率(最低为85%)。但是,当我转到目标文件夹并检查坑报告时,它显示9个类,100%的行覆盖率和96%的突变覆盖率。是什么导致这种巨大差异?在我的pom.xml文件中,我在坑测试和jacoco部分中都排除了一些类。如下所示(类名已更改):

<build>
    <plugins>
        <plugin>
            <groupId>org.pitest</groupId>
            <artifactId>pitest-maven</artifactId>
            <version>1.4.2</version>
                            <configuration>
                <excludedClasses>
                    <excludedClass>path.to.my.class.MyClass10</excludedClass>
                    <excludedClass>path.to.my.class.MyClass11</excludedClass>
                </excludedClasses>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <configuration>
            <excludes>
            <exclude>**/*MyClass10.*</exclude>
            <exclude>**/*MyClass11.*</exclude>
            </excludes>

            </configuration>
            <executions>
                <execution>
                    <id>prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>

                    <configuration>

                        <includes>
                            <include>**/*MyClass1.*</include>
                            <include>**/*MyClass2.*</include>
                            <include>**/*MyClass3.*</include>
                            <include>**/*MyClass4.*</include>
                            <include>**/*MyClass4.*</include>
                            <include>**/*MyClass6.*</include>
                            <include>**/*MyClass7.*</include>
                            <include>**/*MyClass8.*</include>
                            <include>**/*MyClass9.*</include>
                        </includes>
                    </configuration>
                </execution>
                <execution>
                    <id>default-instrument</id>
                    <goals>
                        <goal>instrument</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-restore-instrumented-classes</id>
                    <goals>
                        <goal>restore-instrumented-classes</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>

通过查看控制台中的日志,我已验证Jacoco prepare-agent正确识别了我的包含和排除对象,但仍然存在巨大差异。

问题2)当我键入mvn clean install时构建失败..但是当我键入mvn clean package shade:shade时,项目成功构建。第二个命令是否没有那么严格的检查?

0 个答案:

没有答案