The blog has moved to http://jessehouse.com/ ... 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 - http://trx2html.codeplex.com/
  • 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


10 comments:

Atul Mhetre said...

Hi,

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
trx2html.exe
Create HTML reports of VSTS TestRuns. (c)rido'08
version:0.6.0.2798

Usage: trx2html .trx

D:\share\TRX2HTML_A\0.6>

So I am getting output as -

trx2html.exe
Create HTML reports of VSTS TestRuns. (c)rido'08
version:0.6.0.2798

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

> cd DIRECTORY_WIHT_TRX_FILE

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

Meghana 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-

cd DIRECTORY_WIHT_TRX_FILE

H:\XPDocuments\Visual Studio
2013\trx2hml_0.6.zip\0.6 TRX_FILE_NAME

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

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"

Unknown said...

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

Unknown 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.

Aks said...

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

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?