我使用 VS 2012 使用
vstest.console
生成测试套件,并以 .trx
格式文件获取测试结果。
我想将此结果文件转换为 HTML。我使用了
trx2html
工具。但是当我运行它时出现错误。
错误:System.IO.FileLoadException
trx2html.exe C:\Users...\Desktop 结果.trx
如何解决这个问题? 是否存在其他工具可以将
.trx
文件转换为 html
或 pdf
?
还有一件事,我使用的是orderedtest,所以我的trx文件来自VS2012创建的orderedtest
trx2html 工具和 vs2012 存在一些问题,所以我想您拥有 Codeplex 的最新版本 (http://trx2html.codeplex.com/)。
虽然避免了错误,但这个问题可能对你有用:
我创建了一个 powershell 脚本,将多个 *.trx 文件的摘要整理成一个 html 测试报告:
# Reads all *.trx files from the current working directory, and creates a TestReport.html
Get-Location | Get-ChildItem -Filter '*.trx' -PipelineVariable:file | Get-Content -Raw | ForEach-Object {
$counters = ([xml]$_).TestRun.ResultSummary.Counters
[PSCustomObject]@{
File = Split-Path $file -Leaf
Total = $counters.total
Executed = $counters.executed
Passed = $counters.passed
Failed = $counters.failed
Error = $counters.error
Timeout = $counters.timeout
Aborted = $counters.aborted
Inconclusive = $counters.inconclusive
NotRunnable = $counters.notRunnable
NotExecuted = $counters.notExecuted
Warning = $counters.warning
}
} | ConvertTo-Html > TestReport.html
我将输出限制为这些属性,因为其余的都是“待处理”之类的东西,在测试运行完成后似乎并没有发挥很大的作用。