詹金斯的VStest代码覆盖率报告 [英] VStest code coverage report in jenkins
问题描述
我正在使用Jenkins为.Net项目设置CI.
I am setting CI for .Net project using Jenkins.
我使用了MSTest插件和VStestrunner插件来运行测试. 现在我有.trx文件和.Coverage文件 我在显示代码覆盖率报告时遇到问题
I used MSTest Plugin and VStestrunner plugin to run test. Now I have .trx file and .Coverage file I am facing problem in displaying code coverage report
请帮助我,如果您知道要执行此操作的任何插件.
Please help me is you know any plugin to do this.
推荐答案
要显示覆盖率报告,您需要将其转换为XML格式并使用MSTest插件发布报告. MSTest插件建议( https://wiki.jenkins-ci.org/display/JENKINS /MSTest + Plugin )以使用第三方应用程序将其转换为XML格式和Powershell(您需要为其安装pugin)才能运行它.
To display coverage report you need to convert it in XML format and use MSTest Plugin to publish report. MSTest Plugin recommends (https://wiki.jenkins-ci.org/display/JENKINS/MSTest+Plugin) to use thrid party application to convert in XML format and powershell (you will need to install pugin for it) to run it.
但是,您只能使用PowerShell进行转换.有脚本示例:
However you can convert it with PowerShell only. There is example of script:
$coverageFile = $(get-ChildItem -Path .\TestResults -Recurse -Include *coverage)[0]
$xmlCoverageFile = ".\TestResults\vstest.coveragexml"
Add-Type -path "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Coverage.Analysis.dll"
[string[]] $executablePaths = @($coverageFile)
[string[]] $symbolPaths = @()
$info = [Microsoft.VisualStudio.Coverage.Analysis.CoverageInfo]::CreateFromFile($coverageFile, $executablePaths, $symbolPaths);
$data = $info.BuildDataSet()
$data.WriteXml($xmlCoverageFile)
您可能需要根据您的VS版本修复Microsoft.VisualStudio.Coverage.Analysis.dll的路径.
You maybe will need to fix the path to Microsoft.VisualStudio.Coverage.Analysis.dll according to your VS version.
这篇关于詹金斯的VStest代码覆盖率报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!