sonarqube - 将 InspectCode (Resharper) 和 OpenCover 代码覆盖率报告合并到 Sonar Qube Build 中

标签 sonarqube teamcity resharper jetbrains-ide opencover

我们正在使用 InspectCode-Resharper 插件生成 C# 代码分析报告和 Opencover 代码覆盖率报告(单元测试用例)。

这是在 Teamcity 中依次运行的两个命令。当我们生成 Resharper 分析报告并推送到 Sonar qube 时,我们丢失了代码覆盖率报告。

问题是如何将两个命令合并到一个脚本中或合并两个命令的输出。

这些是我们执行的命令。

OpenCover命令:

F:\BuildSystem\Dependencies\Sonar\OpenCover\4.5.3522\OpenCover.Console.exe -register:user -target:F:\BuildSystem\Dependencies\NUnit\nunit-console-x86.exe -targetargs:"F:\Builds\Sonar\Helix_Sonar_EsdPaymentsBpay\UnitTests\bin\Debug\DummyProject.UnitTests.dll /noshadow" -excludebyattribute:"*.ExcludeFromCodeCoverage*|*.GeneratedCode*" -filter:"+[DummyProject*]* +[App.*]* -[*Tests*]*" -hideskipped:All -mergebyhash -output:coverage-report.xml

检查代码命令

D:\sonar\MSBuild.SonarQube.Runner-1.0\MSBuild.SonarQube.Runner.exe begin /k:"dummy_project" /n:"dummy_project" /v:"sonarqube_project_version" /d:sonar.resharper.cs.reportPath="c:\resharper.xml" /d:sonar.resharper.solutionFile="dummyproject.sln"

"C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild" "D:\CommSee2010\Neon\wwwroot\Apps\dummyproject\dev\dummyproject.sln"

"d:\sonar\jetbrains-commandline-tools\inspectcode.exe" /output="c:\resharper.xml" "D:\CommSee2010\Neon\wwwroot\Apps\dummyproject\dev\dummyproject.sln"

 D:\sonar\MSBuild.SonarQube.Runner-1.0\MSBuild.SonarQube.Runner.exe end

最终解决方案:

"D:\sonar\MSBuild.SonarQube.Runner-2.0\MSBuild.SonarQube.Runner.exe" begin /k:"OFI.CS" /n:"OFI.CS" /v:"1" /d:sonar.cs.opencover.reportsPaths="D:\sonar\output\ofi.Report.opencover.xml" /d:sonar.cs.nunit.reportsPaths="D:\sonar\output\TestResult.xml" /d:sonar.resharper.cs.reportPath="D:\sonar\output\ofi.Report.xml" /d:sonar.resharper.solutionFile="D:\hx\wwwroot\apps\test\dev\test.sln" 

"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" "D:\hx\wwwroot\apps\test\dev\test.sln"

"C:\Program Files (x86)\OpenCover\OpenCover.Console.exe" -register:user -target:"C:\Program Files (x86)\NUnit 2.6.4\bin\nunit-console-x86.exe" -targetargs:"D:\hx\wwwroot\apps\test\dev\UnitTests\bin\Debug\UnitTests.dll /noshadow /xml:D:\sonar\output\TestResult.xml" -filter:"" -mergebyhash -output:"d:\sonar\output\ofi.Report.opencover.xml"

"D:\sonar\resharper\inspectcode.exe" /output="D:\sonar\output\ofi.Report.xml" /profile="D:\hx\wwwroot\apps\test\dev\test.sln.DotSettings" "D:\hx\wwwroot\apps\test\dev\test.sln"

"D:\sonar\MSBuild.SonarQube.Runner-2.0\MSBuild.SonarQube.Runner.exe" end

最佳答案

您需要将 OpenCover 输出文件上传到 Sonar ,例如

/d:sonar.cs.opencover.reportsPaths="coverage-report.xml"

关于sonarqube - 将 InspectCode (Resharper) 和 OpenCover 代码覆盖率报告合并到 Sonar Qube Build 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35448801/

相关文章:

msbuild - SonarQube MSBuild 集成失败 : SonarQube was unable to collect the required information about your projects

c# - TeamCity 中的 MSBuild 步骤考虑 app.config 而不是 web.config 用于 ASP.NET WEB API 项目,导致警告 MSB3247

deployment - WebDeploy:合并内容

c# - 处理 NULL 的最佳方法

java - 在单行中调用 Optional#isPresent() 被报告为未调用

c# - 使用 Roslyn SDK 生成器生成的自定义 SonarQube 规则始终发出类型 "Code Smell"

sonarqube - Sonar 网络用户界面真的很慢

java - 如何在 TeamCity 中很好地展示 ScalaTest 测试

javascript - const 与 let 在 TypeScript(或 Javascript)中的优势

c# - 我该如何修复 : Access to foreach variable in closure resharper warning?