Sonarqube 运行后未显示代码覆盖率 [英] Sonarqube is not showing code coverage after running
问题描述
我正在使用 maven 运行 sonarqube.
我使用以下
当我使用 IntelliJ 的工具运行它时,我得到以下结果.(不是零!)
这是我直接检查 Jacoco 结果的时候.在 $base_direc/target/jacoco/index.html
使用 sonar-scanner
<小时>这是我的 Maven 配置
我的~/.m2/settings.xml
编辑 1:我在日志中发现了这一点.
<小时>我已经编辑了 ~/.m2/settings.xml
添加了
<sonar.host.url>http://localhost:9000/</sonar.host.url></属性>
编辑/usr/local/Cellar/sonarqube/6.3.1/libexec/conf/sonar.properties
添加了 sonar.host.url=http://localhost:9000/
已编辑 /usr/local/etc/sonar-scanner.properties
添加 - sonar.host.url=http://localhost:9000/
以上述所有方式运行应用程序,结果相同,即我可以看到 Jacoco 结果,但在声纳中看不到.
<小时>有没有可能发现bug sonar 拒绝做代码覆盖?!
我找到了解决方案-
我包含的 maven 插件将 Jacoco 的 destfile 和 datafile 配置为 ${basedir}/target/coverage-reports/jacoco-unit.exec
但默认情况下,声纳会读取 ${basedir}/target/jacoco.exec
.我在 http://localhost:9000/settings?category=java 更改了默认值
参考:声纳代码覆盖率
找不到有效的参考链接.这是辅助链接:Baeldung 声纳和 jacoco
I'm running sonarqube with maven.
I have installed it using following way.
Using brew
, I installed mysql
and sonar
.
When I run I get 7 critical bugs but the code coverage for 88 tests is zero
When I run it with IntelliJ's tools, I get the following results. (not zero!)
This is when I check Jacoco results directly. In $base_direc/target/jacoco/index.html
The same code when run with sonar-scanner
This is my maven configuration
My ~/.m2/settings.xml
Edit 1: I have found this in logs.
Edit2:
I have edited ~/.m2/settings.xml
added
<properties>
<sonar.host.url>http://localhost:9000/</sonar.host.url>
</properties>
Edited /usr/local/Cellar/sonarqube/6.3.1/libexec/conf/sonar.properties
added sonar.host.url=http://localhost:9000/
Edited /usr/local/etc/sonar-scanner.properties
added - sonar.host.url=http://localhost:9000/
Ran the application in all above ways and the results were same, i.e, I could see Jacoco results but not in sonar.
Is it possible that if bugs are found sonar refuses to do code coverage?!
I found the solution -
The maven plugin I have included has configuration of Jacoco's destfile and datafile as ${basedir}/target/coverage-reports/jacoco-unit.exec
but by default sonar reads at ${basedir}/target/jacoco.exec
. I changed the default at http://localhost:9000/settings?category=java
Ref: Sonar Code Coverage
Couldn't find the working reference link. Here is aux link: Baeldung Sonar and jacoco
这篇关于Sonarqube 运行后未显示代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!