Lunaat
Lunaat

Reputation: 43

How to convert a ".trx" file to HTML

I generate my tests suite with vstest.console with VS 2012 and get my test result in a .trx format file.

I want to convert this result file toHTML. I used the trx2html tool. But I get an error when I run it.

Error : System.IO.FileLoadException

trx2html.exe C:\Users...\Desktop\result.trx

How can I solve this problem? Do other tools exist that allow converting a .trx file to html or pdf ?

One more thing, I'm using orderedtest so my trx file come from orderedtest created by VS2012

Upvotes: 0

Views: 4184

Answers (2)

Chris
Chris

Reputation: 597

I have created a powershell script collating the summaries of multiple *.trx files into a sing html test report:

# 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

I've limited the output to these properties, as the rest are things like "pending" which seem not to play a big role after the test run completes.

Upvotes: 0

Morcilla de Arroz
Morcilla de Arroz

Reputation: 2182

There were some issues with trx2html tool and vs2012, so I suppose you have the latest version from Codeplex (http://trx2html.codeplex.com/).

Although obviating the error, this question may be useful for you:

How do I format Visual Studio Test results file (.trx) into a more readable format?

Upvotes: 0

Related Questions