使用csv/html报告(而不是* .exec)来提供sonarqube jacoco小部件 [英] Feed sonarqube jacoco widget with csv/html reports (instead of *.exec)

查看:307
本文介绍了使用csv/html报告(而不是* .exec)来提供sonarqube jacoco小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个root Maven项目,该项目下有许多独立的模块(例如module_A,module_B等).

I got a root maven project, under which there are many independent modules (e.g. module_A, module_B, etc.).

这些模块之一是我的集成测试模块,它使用上述所有外部模块. 为了覆盖集成测试所使用的所有模块的代码,我使用了基于maven-ant的变通方法(请参阅

One of these module is my integration-tests module, and it uses all the above external modules. In order to have code coverage for all modules used by integration-tests, I use a workaround based on maven-ant (see this blog post).

上面的代码生成csv/html报告,但是sonarqube jacoco小部件仅解析jacoco * .exec文件-这导致代码覆盖率为0%.

The above generates csv/html report, yet sonarqube jacoco widget parses only jacoco*.exec files - which results in 0% code coverage.

这是上述问题的示例项目

推荐答案

您无需使用该替代方法.您可以为Sonar提供具有以下属性的集成测试覆盖率文件(在执行sonar:sonar目标时应使用该文件):

You don't need to use that workaround. You can provide Sonar with integration tests coverage file with following property (you shall use it while executing sonar:sonar goal):

-Dsonar.jacoco.itReportPath=<coverage_file>

这里是详细的文档:

http://docs. codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests+for+Java+Project

总结:

  1. 编译所有模块.

  1. Compile all your modules.

在启用了jacoco的情况下执行集成测试.

Execute integration tests with jacoco enabled.

执行Maven Sonar构建,在命令行中添加提及的属性.

Execute Maven Sonar build adding mentioned property in command line.

我已经准备了示例项目,可以生成单元和集成覆盖率结果,您可以在此处进行检查:

I have prepared example project generating both unit and integration coverage results, you can check it here:

https://github.com/octosan/unit-并与声纳整合jacoco-coverage

您必须:

  • 下载最新的Sonarqube版本并启动它
  • 执行命令:
mvn clean install sonar:sonar -Dsonar.jacoco.itReportPath=<absolute_path>/itest/target/jacoco-it.exec

  • 在Sonar的项目仪表板中添加希望覆盖的集成范围
  • 这篇关于使用csv/html报告(而不是* .exec)来提供sonarqube jacoco小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆