Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven Jacoco不计算子模块的覆盖率_Maven_Code Coverage_Jacoco_Maven Surefire Plugin_Jacoco Maven Plugin - Fatal编程技术网

Maven Jacoco不计算子模块的覆盖率

Maven Jacoco不计算子模块的覆盖率,maven,code-coverage,jacoco,maven-surefire-plugin,jacoco-maven-plugin,Maven,Code Coverage,Jacoco,Maven Surefire Plugin,Jacoco Maven Plugin,考虑一个多模块maven项目 Parent pom.xml common src->main->java->a -> b SomeUtil.java pom.xml service src->main->test->p->q SomeServiceIT.java pom.xml 比如说服务依赖于公共,而服务有SomeServi

考虑一个多模块maven项目

Parent
    pom.xml
    common
        src->main->java->a -> b 
            SomeUtil.java
    pom.xml
    service
        src->main->test->p->q
            SomeServiceIT.java
    pom.xml
比如说服务依赖于公共,而服务有SomeServiceIT,它在公共中间接测试SomeUtil

生成的覆盖率报告显示SomeUtil的覆盖率为0%,而它本应至少显示一些覆盖率

我该如何解决这个问题

我正在使用以下插件

jacoco-maven-plugin -> 0.8.1
maven-surefire-plugin -> 2.22.0
maven-failsafe-plugin -> 2.22.0
sonar-maven-plugin -> 3.2
以下是我的配置

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>${jacoco.maven.plugin.version}</version>
    <configuration>
        <destFile>${project.basedir}/../target/coverage-reports/jacoco.exec</destFile>
        <append>true</append>
    </configuration>
    <executions>
        <execution>
        <id>jacoco-initialize</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>

        <execution>
            <id>jacoco-merge</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>merge</goal>
            </goals>
            <configuration>
                <fileSets>
                    <fileset>
                        <directory>${project.build.directory}/../target/coverage-reports/</directory>
                        <includes>
                            <include>*.exec</include>
                        </includes>
                    </fileset>
                </fileSets>
                <destFile>${project.build.directory}/../target/coverage-reports/jacoco.exec</destFile>
            </configuration>
        </execution>

        <execution>
            <id>jacoco-site</id>
            <phase>package</phase>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<plugin>
    <!-- Separates the unit tests from the integration tests. -->
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${maven.surefire.plugin.version}</version>
    <configuration>
        <trimStackTrace>false</trimStackTrace>
    </configuration>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>${maven.failsafe.plugin.version}</version>
    <configuration>
        <forkCount>3C</forkCount>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>integration-test</goal>
            </goals>
        </execution>
    </executions>
</plugin>

org.jacoco
jacocomaven插件
${jacoco.maven.plugin.version}
${project.basedir}/./target/coverage reports/jacoco.exec
真的
jacoco初始化
配制剂
雅科科合并
整合后测试
合并
${project.build.directory}/./target/coverage报告/
*行政长官
${project.build.directory}/./target/coverage reports/jacoco.exec
杰科科遗址
包裹
报告
org.apache.maven.plugins
maven surefire插件
${maven.surefire.plugin.version}
假的
org.apache.maven.plugins
maven故障保护插件
${maven.failsafe.plugin.version}
3C
集成测试

首先始终对齐surefire/failsafe插件,这意味着使用相同版本的surefire/failsafe插件…可能重复