问题描述
Maven项目由8个模块组成,其中6个是具有JUnit 4的Java和2个具有JUnit 5测试的Kotlin。全部都从父级继承相同的Sonar / JaCoCo配置,但是覆盖率仅针对Java模块进行计算。对于Kotlin / JUnit 5模块,尽管进行了多次测试,但SonarQube仍将显示0%的覆盖率。 单元测试和集成测试都将由maven执行,仅不会确定这两个模块的适用范围。
这是父级中的JaCoCo配置,省略了不相关的部分:
<project>
<properties>
<sonar.jacoco.reportPath>${java.io.tmpdir}/coverage/bmp.core/jacoco.exec</sonar.jacoco.reportPath>
...
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>jacoco-initialize-unittest</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${sonar.jacoco.reportPath}</destFile>
<propertyName>jacoco.agent.arg</propertyName>
<append>true</append>
</configuration>
</execution>
<execution>
<id>jacoco-initialize-integrationtest</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${sonar.jacoco.reportPath}</destFile>
<propertyName>jacoco.agent.arg</propertyName>
<append>true</append>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
...
<profiles>
<profile>
<id>unit-tests</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>unit-tests</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration combine.self="override">
<groups>at.wrwks.pipe.commons.test.category.UnitTest</groups>
<!-- to externally configure test groups that should be excluded -->
<excludedGroups>${test.excluded.groups}</excludedGroups>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<!--suppress MavenModelinspection -->
<argLine>
${jacoco.agent.arg}
</argLine>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
...
</project>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)