问题
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