将 InspectCode (Resharper) 和 OpenCover 代码覆盖率报告合并到 Sonar Qube Build 中
Merge InspectCode (Resharper) and OpenCover code coverage report into Sonar Qube Build
我们正在使用 InspectCode- Resharper 插件生成 C# 代码分析报告,并使用 Opencover 生成代码覆盖率报告(单元测试用例)。
这是Teamcity中依次运行的两条命令。当我们生成 Resharper 分析报告并推送到 sonar qube 时,我们丢失了代码覆盖率报告。
问题是如何将两个命令合并到一个脚本中或合并两个命令的输出。
这些是我们执行的命令。
OpenCover 命令:
F:\BuildSystem\Dependencies\Sonar\OpenCover.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
InspectCode 命令
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.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.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 输出文件上传到声纳,例如
/d:sonar.cs.opencover.reportsPaths="coverage-report.xml"
我们正在使用 InspectCode- Resharper 插件生成 C# 代码分析报告,并使用 Opencover 生成代码覆盖率报告(单元测试用例)。
这是Teamcity中依次运行的两条命令。当我们生成 Resharper 分析报告并推送到 sonar qube 时,我们丢失了代码覆盖率报告。
问题是如何将两个命令合并到一个脚本中或合并两个命令的输出。
这些是我们执行的命令。
OpenCover 命令:
F:\BuildSystem\Dependencies\Sonar\OpenCover.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
InspectCode 命令
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.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.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 输出文件上传到声纳,例如
/d:sonar.cs.opencover.reportsPaths="coverage-report.xml"