'Is there a way to get a test results and coverage html report from MSTest
I'd like to be able to produce a HTML based report from the Results.trx and data.coverage files that MSTest creates. Ideally this would just list any failures, and show some basic coverage stats.
Does anyone know of a tool that does this?
Solution 1:[1]
you can use TRXER tool to generate HTML reports from trx file. Download TrxerConsole.exe file from here
- Build/Rebuild the project to create .dll file.
- If your project name is UnitTest1 then the .dll file name will be UnitTest1.dll. Go to the location of .dll like
C:\Users\NAME\source\repos\UnitTest1 \UnitTest1 \bin\Debug\netcoreapp3.1\UnitTest1.dll
- Open Developer command prompt of Visual studio 2019
- Run command to set the location
cd C:\Users\NAME\source\repos\UnitTest1\UnitTest1\bin\Debug\netcoreapp3.1\UnitTest1.dll
- Run the Command to Generate trx file:
vstest.console.exe UnitTest1.dll /logger:trx
Trx file will be generated in the folder TestReults which is present in the same location where project dll file is present.
If TrxerConsole.exe is in downloads then run the command to convert into HTML.
Path of trxerconsole.exe file then space then Path of trxfile as below
C:\Users\NAME\Downloads\TrxerConsole.exe C:\Users\NAME\source\repos\DesktopWithMSTest\DesktopWithMSTest\bin\Debug\netcoreapp3.1\TestResults\TestResult.trx
- HTML file will be generated in same TestResults Folder.
link to refer
your Reports will look like:
Solution 2:[2]
Actually we did that using the open source tool Trx2Html
Its really simple - gets trx file and output html. There are specific versions for VS2005 trx and VS2008 trx.
Solution 3:[3]
You can publish to the report server and then the reports will be available from a web interface.
Solution 4:[4]
( I did it in PowerShell)
You need this dll
Microsoft.VisualStudio.Coverage.Analysis.dll
then this line will turn .coverage into an xml file (which the .trx already is)
$dataStore = ([Microsoft.VisualStudio.CodeCoverage.CoverageInfoManager]::CreateInfoFromFile("$homeDir\tests.coverage")).BuildDataSet($null)
$dataStore.WriteXml("$homeDir\Coverage.xml")
Then you could use the MsTest xsl file from cruisecontrol.net to put the test results in a nice html format, and I have an XSL for the coverage. WHich won't fit here. I wish they had a way to upload files. Email me alex dot hutton at hotmail, and I can get you the xsl to display that coverage
Solution 5:[5]
The trx files are fairly simple xml documents that can easily be processed with XSLT to produce flexible and customized reports.
If you google trx and xslt you'le find a number of examples to get you started.
Solution 6:[6]
I have added a codeplex project for this, you can generate the html from trx as well as add code-coverage data to the same report. http://trxtohtml.codeplex.com/
Solution 7:[7]
try the new trx2html.codeplex.com it's not based on XSLT, but in LINQ2XML so it's easier to extend
Solution 8:[8]
I am writing a simple batch file to convert your XML report into HTML
Pre-requisites
- Download trx2html.exe from here
- Paste it to any location on your machine where XML file is being generated
Create a report.bat file and paste the code given below
@echo off ::*****************************Constants***************************************************************** set "trxFileName=TestResult"
set "trx2html_path=C:\Users\Desktop\0.6\TrxerConsole.exe" ::********************************************************************************************echo ------------------------"Generating test report "---------------------------------------------- %trx2html_path% ".\Results\%trxFileName%"
echo -----------------------"Test Report Generated at location=.\Results\%trxFileName%"------------ pause
Solution 9:[9]
I have created a tool to generate html from trx. The tool is available from Nuget.org.
Install as global tool:
dotnet tool install --global trxlog2html --version 1.0.0
Install as local tool:
dotnet new tool-manifest
dotnet tool install --local trxlog2html --version 1.0.0
Converting the TRX to html file:
After installation, you can convert the trx file to html file with the following command.
dotnet run trxlog2html -i [input trx file path] -o [output html file path]
See the links below for more information.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow

