【发布时间】:2019-12-26 14:08:58
【问题描述】:
我正在为一个 Maven 项目设置 Jacoco 覆盖范围。我想在 VSTS 中发布此报道。 我成功地获得了正确的覆盖范围,并且它为我项目的所有子模块发布,但没有出现图片(Jacoco 生成的 Index.html 文件和 VSTS 板中都没有)。见screenshot。
你遇到过这样的问题吗?请问如何解决这个问题?
谢谢!
在 VSTS 管道中添加的任务:
# Publish code coverage results # Publish Cobertura or JaCoCo code coverage results from a build - task: PublishCodeCoverageResults@1 inputs: codeCoverageTool: 'JaCoCo' summaryFileLocation: '**/jacoco-ut/*.xml' reportDirectory: '**/jacoco-ut/' additionalCodeCoverageFiles: '**/coverage-reports/jacoco-ut.exec' failIfCoverageEmpty: false
聚合器模块的 POM 配置:
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <executions> <execution> <id>report-aggregate</id> <phase>prepare-package</phase> <goals> <goal>report-aggregate</goal> </goals> <configuration> <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile> <outputDirectory> ${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> </configuration> </execution> </executions> </plugin>
Maven 父模块的 POM:
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.version}</version> <executions> <execution> <goals> <goal>prepare-agent</goal> </goals> </execution> </executions> </plugin>
对于每个子模块,在 POM 配置下:
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <executions> <execution> <id>report</id> <phase>test</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin>
【问题讨论】:
-
能否将您的评论转换为答案? stackoverflow.com/help/self-answer
标签: azure-devops azure-pipelines jacoco maven-surefire-plugin jacoco-maven-plugin