The blog has moved to ... Many google searches point here so I am leaving it operational, but there will be no new posts.

Friday, March 11, 2011

MSTest output result to HTML

MSTest generates trx (xml) files which can be viewed in Visual Studio. But often you will be executing MSTest from the command line via your Continuous Integration (CI) server and you will want to view them in an html format outside Visual Studio.

trx2html to the rescue!

  • download the zip file here -
  • unzip and put the files somewhere
    • I choose C:\Program Files (x86)\trx2html
  • execute it from the command line 

# in YourTestProject\bin\Release
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe" /testcontainer:YourTestProject.dll /resultsfile:TestResult.trx

"C:\Program Files (x86)\trx2html\0.6\trx2html.exe" TestResult.trx
# outputs TestResult.trx.htm


Atul Mhetre said...


I am having problem in converting trx file into HTML file.

I navigate to trx2htm.exe in command prompt and used command as - D:\share\TRX2HTML_A\0.6>cd D:\share\TRX2HTML_A\0.6

D:\share\TRX2HTML_A\0.6>trx2html atul.mhetre_NTPC01395 2013-01-22 15_05_51.trx
Create HTML reports of VSTS TestRuns. (c)rido'08

Usage: trx2html .trx


So I am getting output as -

Create HTML reports of VSTS TestRuns. (c)rido'08

Usage: trx2html .trx

And no html file is generating. Please help.

House 9 said...

Try running it from the directory that your trx file is in


> "D:\share\TRX2HTML_A\0.6\trx2html.exe" TRX_FILE_NAME

Meenal Kuber said...

I am using console application (type)in visual studio 2013 with selenium web driver.

I am testing functionality of web app.

Need to generate HTML test report for tcs run.
I followed steps you specified-


H:\XPDocuments\Visual Studio
2013\\0.6 TRX_FILE_NAME

but on command line still getting-
Create HTML reports of VSTS TestRuns. (c)rido'08

Usage: trx2html .trx

So how to see html file?
where (in which folder) its get generated ?

Thanks a lot.

Mark said...

My guess is that the problem in both of these cases the .trx file has a space in the file name. Try enclosing the file name in double quotes like this:

trx2html "atul.mhetre_NTPC01395 2013-01-22 15_05_51.trx"

Swathy Selvaraj said...

Thank you. Using trx file location in comments worked for me.

kiran venu said...

i want to use it with jenkins did any tried using it ?

Ajit Jadhav said...

i am not able to fing trx file after tests execution.

Akanksha Agrawal said...

Hi - Its gvig me below error
C:\vNext-Dev>"C:\Program Files (x86)\trx2html\trx2html.exe" testresults1.trx
Create HTML reports of VSTS TestRuns. (c)rido'08

Processing vs2010 trx file

Unhandled Exception: System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.Xml.Xsl.CompiledQuery.Script1.RemoveAssemblyName(String asm)
at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current)
at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
at System.Xml.Xsl.XmlILCommand.Execute(XmlReader contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, Stream results)
at System.Xml.Xsl.XslCompiledTransform.Transform(String inputUri, String resultsFile)
at trx2html.Program.Transform(String fileName, XmlDocument xsl)
at trx2html.Program.Main(String[] args)

korapati said...

System generated .trx file is very lengthy , just rename and place .trx file with location .it will convert .trx to .trx.html

Preeti said...

Hi, I am also getting same error message (Unhandled Exception: System.ArgumentOutOfRangeException) Is there any resolution for the same?