简体   繁体   中英

Visual Studio 2012 Unit Test Report

I need to create some report of the execution of my unit test cases (quantity of tests passed, failed and ignored). I looked around the internet but I didn't find any way to generate this. Does someone knows a simple (or complex) way to generate a unit test report locally? (I said locally because I have found a solution using the test manager but is not feasible to me righ now).

There is no option from the Visual Studio UI, but this can be accomplished from the command line. navigate to your solution directory and run the following command from the Visual Studio 2013 command line:

vstest.console.exe /logger:trx .\\TestProject\\bin\\debug\\YourUnitTestAssembly.dll

This will create a TestResults folder under your solution root and drop a .trx file. By opening that file into Visual Studio you should see something like this:

在此处输入图片说明

The .trx file is easy to parse XML and can be converted into human readable data using an XSLT, as explained in this other question .

Normally Visual Studio creates this file during the run, but deletes it afterwards. It looks like my instance of Visual Studio will actually create such a trx file and keep it in a $(solutionroot)\\TestResults\\{GUID} directory when I use the Analyze code coverage feature:

在此处输入图片说明

在此处输入图片说明

To see if your version of Visual studio has the Trx logger installed, run the following command from a Visual Studio command prompt:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM