如何将业力测试报告上传到声纳? [英] How to upload karma test report to sonar?

查看:30
本文介绍了如何将业力测试报告上传到声纳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我配置了 karma,这让我的覆盖率报告非常好.
它以 lcov 格式给我.参考这个 http://docs.sonarqube.org/display/PLUG/JavaScript+覆盖率+结果+导入
lcov报告可以上传到声纳.

I have karma configured which gives me coverage report perfectly fine.
It gives me in lcov format. Referring to this http://docs.sonarqube.org/display/PLUG/JavaScript+Coverage+Results+Import
lcov report can be uploaded to sonar.

我已经在声纳中安装了插件.我的项目是通过 ant 脚本构建的,所以我添加了

I have installed the plugin in sonar. My project builds through ant scripts so i have added

<property name="sonar.javascript.lcov.reportPath" value="/lcov.info"/>

我在一些博客上读到 lcov 需要更正,以便声纳能够理解它.我已经完成了.
所以 lcov 被生成并且格式正确.

I read on some blogs that lcov needs to be corrected so that sonar can understand it. I am done with it.
So lcov gets generated and is in the correct format.

由于某种原因,声纳无法找到我的 lcov 报告并且不解析报告.我检查了我的路径它是正确的.
我错过了什么吗?任何帮助将不胜感激.

For some reason the sonar is unable to find my lcov report and does not parse the report. I checked my path it is correct.
Am I missing on something ? Any help would be appreciated.

推荐答案

lcov.info 可能有不正确的文件路径.工作服等其他工具工作正常,声纳需要相对路径.这是我的 lcov.info 的样子./source/app/simplebind/child.component.ts 不正确,需要声纳 src/app/simplebind/child.component.ts

lcov.info may have incorrect file paths. Other tools like coveralls work fine and sonar expects the relative path. Here is how my lcov.info looked. /source/app/simplebind/child.component.ts was incorrect and sonarqube expected src/app/simplebind/child.component.ts

TN:
SF:/source/app/simplebind/child.component.ts
FN:11,(anonymous_3)
FN:17,ChildComponent
FN:22,(anonymous_5)
FNF:3
FNH:3
FNDA:1,(anonymous_3)
FNDA:3,ChildComponent
FNDA:1,(anonymous_5)
DA:1,1
DA:3,1
DA:11,1

使用以下命令替换lcov.info中的文件路径.您可以在 jenkins shell 的 gulp build 之后执行它.

Use following command to replace the file path in lcov.info. You can execute it after gulp build from your jenkins shell.

sed -i -- 's/\/source/src/g' report/remap/lcov.info

也适用于 Angular2 Typescript Sonar 插件.https://github.com/Pablissimo/SonarTsPlugin

Works fine for Angular2 Typescript Sonar plugin as well. https://github.com/Pablissimo/SonarTsPlugin

这篇关于如何将业力测试报告上传到声纳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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