Feed sonarqube jacoco widget with csv/html reports (instead of *.exec)

笑着哭i 提交于 2020-01-24 20:28:33

问题


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

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).

Problem is:

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

Question is:


EDIT

here's an example project for the problem above.


回答1:


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>

Here is detailed documentation:

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

To sum up:

  1. Compile all your modules.

  2. Execute integration tests with jacoco enabled.

  3. 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-and-integration-jacoco-coverage-with-sonar

You have to:

  • download newest Sonarqube version and start it
  • execute command:
mvn clean install sonar:sonar -Dsonar.jacoco.itReportPath=<absolute_path>/itest/target/jacoco-it.exec
  • add integration coverage widged in project dashboard in Sonar


来源:https://stackoverflow.com/questions/26084729/feed-sonarqube-jacoco-widget-with-csv-html-reports-instead-of-exec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!