如何告诉Sonar使用我的LCOV文件进行代码覆盖 [英] How to tell Sonar to use my LCOV file for Code Coverage

查看:112
本文介绍了如何告诉Sonar使用我的LCOV文件进行代码覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个包含一堆javascript文件的Jenkins作业。
我们通过grunt构建我们的项目,在构建结束时,我们运行JSCover来运行我们的单元测试并收集代码覆盖率。一切正常。我们得到了一个不错的LCOV文件。

We have a Jenkins job that contains a bunch of javascript files. We build our project via grunt, and at the end of the build we run JSCover to run our unit tests and collect code coverage. It all works. We get a nice LCOV file.

我们现在想要将LCOV文件上传到Sonar,我不知道该怎么做。
我们正在从Jenkins构建我们的项目作为一个自由风格的项目。

We now want to upload the LCOV file to Sonar, and I'm not sure how to do this. We are building our project from Jenkins as a free style project.

我试着玩各种声纳的项目属性,但没有爱:

I tried playing around with various project properties for sonar, but no love:

# project metadata (required)
sonar.projectKey=my.project
sonar.projectName=My Project
sonar.projectVersion=1.0
# path to source directories (required)
sonar.sources=src

# The value of the property must be the key of the language.
sonar.language=java (I tried js and javascript, but no love. Plugin is not installed.  Actually, I don't care about the language, since I am already generating the LCOV file during the build.  I just need Sonar to use this LCOV file.)

# Advanced parameters
sonar.javascript.jstestdriver.reportsfolder=target/surefire-reports
sonar.javascript.jstestdriver.coveragefile=target/test-coverage/jscover.lcov
sonar.dynamicAnalysis=reuseReports

我怀疑问题是在高级参数下,但我不知道如何告诉Sonar,请使用我的LCOV文件进行代码覆盖。

I suspect the problem is under the "Advanced Parameters", but I don't know how to tell Sonar, "Please use my LCOV file for Code Coverage".

推荐答案

您可以查看此示例项目,其中LCOV报告的路径在 sonar-project.properties 文件中指定。

You can have a look at this sample project where the path to a LCOV report is specified in the sonar-project.properties file.

请注意,某些属性名称包含在最新版本的Javascript插件中已更改。

Note that some property names have changed in the last version of the Javascript plugin.

这篇关于如何告诉Sonar使用我的LCOV文件进行代码覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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