Jacoco 和 Sonar 代码覆盖率? [英] Jacoco and Sonar code coverage?

查看:40
本文介绍了Jacoco 和 Sonar 代码覆盖率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用: JaCoCo 0.5.3、Maven2、Sonar 2.14、sonar-maven-plugin 1.8、SùartGWT 3.0
目前正在尝试:在我的 Selenium 单元测试的 Sonar 上获取代码覆盖率.
问题: 尽管传感器正确启动,但代码覆盖率并未从 0% 移动,请分析正确生成的 jacoco.exec.
资源: https://gist.github.com/2888912 pom.xml

Using : JaCoCo 0.5.3, Maven2, Sonar 2.14, sonar-maven-plugin 1.8, SùartGWT 3.0
Currently trying to : Get code coverage on Sonar of my Selenium unit tests.
Problem : Code coverage doesn't move from 0% although the sensor is launched properly, analyse the jacoco.exec which is correctly generated.
Ressources : https://gist.github.com/2888912 The pom.xml

我试图获得代码覆盖率已经大约 2 周了.我将声纳从 2.10 升级到 2.14,更改了每个声纳属性,尝试了插件 jacoco(用于 maven),但我仍然没有得到任何结果.所以如果有人遇到同样的问题并找到了解决方案,你能告诉我你是如何工作的吗?

It's been about 2 weeks I'm trying to get code coverage. I upgraded the Sonar from 2.10 to 2.14, changed every single sonar property, tried the plugin jacoco (for maven) and I still DON'T get any results. So if someone had the same problems and found the solution, could you please tell me how you amde it work ?

我很确定我的测试必须产生至少 0.5% 的代码覆盖率.我的 Selenium 测试实际上是在 SeleniumTestLoginEntry.java 中执行的,它有什么影响吗?我必须称它为 TestLoginEntry.java 吗?(测试的类是LoginEntry.java)我正在使用surefire来启动JaCoCo的javaagent(见标签),它实际上生成了jacoco.exec.

I'm quite sure my tests must generate at least 0.5% of code coverage. My Selenium tests are actually executed in SeleniumTestLoginEntry.java, does it have any incidence ? Must I call it TestLoginEntry.java ? (The tested class is LoginEntry.java) I'm using surefire to start the javaagent of JaCoCo (see the tag) and it actually GENERATES the jacoco.exec.

请给我一些帮助,我完全迷路了,我只剩下一周的时间来让它工作...... :(
提前致谢.

Please give me some help, I'm totally lost I have only one week left to make it work... :(
Thanks in advance.

推荐答案

我的设置与你的设置略有不同,使用 Ant 和 Sonar 3.01,但是...有一个属性对我有用,当我查看时,这似乎几乎完全没有记录.我注意到最近几天 wiki 页面有更新,这可能改变了文档的情况.

I'm in a slightly different setup than you are, using Ant and Sonar 3.01, but... there was one property that did the trick for me, that seemed to be almost entirely undocumented when I looked. I notice the wiki pages have had updates in the last couple of days, which may have changed the doc situation.

<property name="sonar.core.codeCoveragePlugin" value="jacoco" />
<property name="sonar.jacoco.reportPath" value="${test.log.dir}/jacoco.exec"/>

sonar.jacoco.reportPath 显式设置为文件,而不是目录,这最终对我有用.

Setting sonar.jacoco.reportPath explicitly to the file, not a directory, was what finally worked for me.

这篇关于Jacoco 和 Sonar 代码覆盖率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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