Vik*_*rde 7 java maven jacoco-maven-plugin
我们有一个多模块 Maven 项目。我们用的是java8。
\n-Parent\n-- Child 1\n-- Child 2\n-- Coverage-Report\n
Run Code Online (Sandbox Code Playgroud)\n所有项目都有单元测试用例,运行良好,覆盖率超过 85%。父 pom.xml 文件具有 jacoco-profile 和 jacoco-maven-plugin 插件,如下所示
\n <plugin>\n <groupId>org.jacoco</groupId>\n <artifactId>jacoco-maven-plugin</artifactId>\n <version>0.8.6</version>\n <configuration>\n <destFile>${sonar.coverage.jacoco.xmlReportPaths}</destFile>\n <append>true</append>\n </configuration>\n <executions>\n <execution>\n <id>prepare-agent</id>\n <goals>\n <goal>prepare-agent</goal>\n </goals>\n </execution>\n <execution>\n <id>report</id>\n <phase>verify</phase>\n <goals>\n <goal>report</goal>\n </goals>\n </execution>\n </executions>\n </plugin>\n
Run Code Online (Sandbox Code Playgroud)\n在Coverage-Report模块中,只有pom.xml用于聚合报告。它的配置文件为 jacoco 如下
\n <profile>\n <id>jacoco</id>\n <activation/>\n <build>\n <plugins>\n <plugin>\n <groupId>org.jacoco</groupId>\n <artifactId>jacoco-maven-plugin</artifactId>\n <executions>\n <execution>\n <id>report-aggregate</id>\n <phase>verify</phase>\n <goals>\n <goal>report-aggregate</goal>\n </goals>\n </execution>\n </executions>\n </plugin>\n </plugins>\n </build>\n </profile>\n
Run Code Online (Sandbox Code Playgroud)\n要生成报告,我们使用以下命令
\nmvn clean verify -Pjacoco\n
Run Code Online (Sandbox Code Playgroud)\n我们确实看到父 pom.xml 中提到的文件正在生成
\n<sonar.coverage.jacoco.xmlReportPaths>${maven.multiModuleProjectDirectory}/ocapi-promotion-service-coverage-report/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>\n \n
Run Code Online (Sandbox Code Playgroud)\n然而,这个文件 jacoco.xml 不是正确的 XML。它有一些编码字符,如下所示。(该文件中的几行)
\n\xef\xbf\xbd\xef\xbf\xbdca6191af5ae0-1a24a201}-\xef\xbf\xbdSy}-\xc6\x8c|pW\xef\xbf\xbd\\\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd;org/springframework/context/annotation/BeanAnnotationHelper\xef\xbf\xbdw~\xef\xbf\xbdj\xef\xbf\xbdzI\xef\xbf\xbdZMorg/springframework/boot/autoconfigure/condition/FilteringSpringBootCondition\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbde\xd6\xa2+org/sp\n
Run Code Online (Sandbox Code Playgroud)\n在詹金斯上我们看到以下错误
\nCaused by: java.nio.charset.MalformedInputException: Input length = 1\n
Run Code Online (Sandbox Code Playgroud)\n我关注了声纳源社区https://community.sonarsource.com/t/coverage-test-data-importing-jacoco-coverage-report-in-xml-format/12151的一篇文章,其中提供了一些步骤。但我无法生成 XML 文件。请帮忙。
\n 归档时间: |
|
查看次数: |
2238 次 |
最近记录: |