Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying results filename for vstest.console.exe

May be a silly question, but does anybody know how to specify the output filename of a VSTEST.Console.exe run? My command line is as follows:

 vstest.console.exe [assembly] /logger:trx 

At the end of the run, the following comes up in the console:

 ResultsFile: somepath\TestResults\{username}_{workstation} {timestamp}.trx 

I tried using the .runsettings file to specify the output location, but that only seems to control the output directory, but not the output file. Have not found anything else that would seem to control it.

I want to parse the TRX file and generate a report out of it (this already works, but if I can't specify the output path of the TRX file, I won't know where to pick it up from in the scripts!)

I have to be missing something here...

like image 361
syazdani Avatar asked Jan 23 '13 15:01

syazdani


People also ask

What is VSTest console exe?

VSTest. Console.exe is the command-line tool to run tests. You can specify several options in any order on the command line. These options are listed in General command-line options. The MSTest adapter in Visual Studio also works in legacy mode (equivalent to running tests with mstest.exe) for compatibility.

Where is TRX file located?

The TRX logger doesn't support any parameters (unlike the TFS publisher logger). The logger assembly is located in "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions\Microsoft.

How do I create a Runsettings file?

Create a run settings file and customize it Add a run settings file to your solution. In Solution Explorer, on the shortcut menu of your solution, choose Add > New Item, and select XML File. Save the file with a name such as test. runsettings.


1 Answers

EDIT: See @AnaFranco's answer - apparently since VS2017 the file name can be configured like so:

vstest.console.exe [assembly] /logger:trx;LogFileName=[filename].trx 

I'll leave the old answer for posterity and pre-2017 versions.


Nope, you're not missing anything. The TRX logger doesn't support any parameters (unlike the TFS publisher logger).

The logger assembly is located in "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions\Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.dll". If you check it out in your favorite .NET decompiler, you'll see the method TrxLogger.GetTrxFileName. It uses some basic knowledge about the current test run to produce the mangled name of form {username}_{workstation} {timestamp}.trx and is in no appreciable way configurable.

As far as I can tell, the TRX file is created in the TestResults\ folder under the current working directory unless otherwise configured. What you can do is:

  • Create a new temporary folder
  • Change the current directory to it
  • Run the test runner
  • Scan the folder for the result .trx file using your favorite recursive file search method and you're done

At least that is what I do in our build (MSBuild, sob):

<ItemGroup>   <TestResult Include="**\*.trx"/> </ItemGroup> 

I.e, gather all .trx files under the current directory and stuff them into the @(TestResult) item group for further processing.

like image 114
Stefan Dragnev Avatar answered Sep 22 '22 02:09

Stefan Dragnev