VStest code coverage report in jenkins

▼魔方 西西 提交于 2019-12-21 06:04:04

问题


I am setting CI for .Net project using Jenkins.

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.


回答1:


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.

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)

You maybe will need to fix the path to Microsoft.VisualStudio.Coverage.Analysis.dll according to your VS version.



来源:https://stackoverflow.com/questions/30215324/vstest-code-coverage-report-in-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!