javascript 如何告诉声纳使用我的 LCOV 文件进行代码覆盖
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15745726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to tell Sonar to use my LCOV file for Code Coverage
提问by grayaii
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.
我们有一个 Jenkins 作业,其中包含一堆 javascript 文件。我们通过 grunt 构建我们的项目,并在构建结束时运行 JSCover 来运行我们的单元测试并收集代码覆盖率。这一切都有效。我们得到了一个不错的 LCOV 文件。
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.
我们现在想将 LCOV 文件上传到 Sonar,但我不知道该怎么做。我们正在从 Jenkins 构建我们的项目作为一个自由风格的项目。
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
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 文件进行代码覆盖”。
采纳答案by Fabrice - SonarSource Team
You can have a look at this sample projectwhere the path to a LCOV report is specified in the sonar-project.properties
file.
您可以查看此示例项目,其中在sonar-project.properties
文件中指定了 LCOV 报告的路径。
Note that some property names have changed in the last version of the Javascript plugin.
请注意,在最新版本的 Javascript 插件中,某些属性名称已更改。