考虑一个多模块的Maven项目
Parent
pom.xml
common
src->main->java->a -> b
SomeUtil.java
pom.xml
service
src->main->test->p->q
SomeServiceIT.java
pom.xml
说服务依赖于 common ,服务具有 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>