Is there a way to get a test results and coverage html report from MSTest
Asked Answered
P

9

9

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?

Peregrinate answered 24/2, 2009 at 12:30 Comment(1)
You can also try ReportUnit: relevantcodes.com/reportunit-report-generatorKitchens
C
5

you can use TRXER tool to generate HTML reports from trx file. Download TrxerConsole.exe file from here

  1. Build/Rebuild the project to create .dll file.
  2. 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

  1. Open Developer command prompt of Visual studio 2019
  2. Run command to set the location

cd C:\Users\NAME\source\repos\UnitTest1\UnitTest1\bin\Debug\netcoreapp3.1\UnitTest1.dll

  1. Run the Command to Generate trx file:

vstest.console.exe UnitTest1.dll /logger:trx

  1. Trx file will be generated in the folder TestReults which is present in the same location where project dll file is present.

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

  1. HTML file will be generated in same TestResults Folder.

link to refer

your Reports will look like:

Reports

Curator answered 27/2, 2020 at 6:24 Comment(1)
Works great after applying the fix github.com/NivNavick/trxer/issues/40Cardholder
A
3

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.

Adamsun answered 10/3, 2009 at 17:15 Comment(0)
R
0

You can publish to the report server and then the reports will be available from a web interface.

Rack answered 24/2, 2009 at 12:37 Comment(0)
W
0

( 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

Whitehorse answered 24/2, 2009 at 12:39 Comment(0)
D
0

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.

Dikmen answered 29/3, 2009 at 23:42 Comment(0)
T
0

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/

Truax answered 20/4, 2010 at 18:32 Comment(0)
M
0

try the new trx2html.codeplex.com it's not based on XSLT, but in LINQ2XML so it's easier to extend

Merissameristem answered 16/5, 2011 at 10:24 Comment(1)
I archived the trx2html. where is the .exe file from the folders. I couldn't find them :(Freedman
H
0

I am writing a simple batch file to convert your XML report into HTML

Pre-requisites

  1. Download trx2html.exe from here
  2. Paste it to any location on your machine where XML file is being generated
  3. 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

Habakkuk answered 29/3, 2018 at 8:50 Comment(0)
S
0

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.

https://github.com/HikosakaRyo/trxlog2html

https://www.nuget.org/packages/trxlog2html/

Sixgun answered 24/2, 2022 at 5:19 Comment(1)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewMaking

© 2022 - 2024 — McMap. All rights reserved.