Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does TFS store UNIT test results?

I am running:

  1. VS 2012
  2. Latest version of TFS
  3. A separate build agent on a dedicated VM

My tests are gated on build and unit tests. On my build box I have found the following folder: C:\Builds\4\SolutionName\SolutionName\TestResults, but sadly it is empty. I would like to find and parse the test result files. I would like to know what serves up the results of the build and how to call that from a third party tool. Does anyone know?

like image 676
Ian Avatar asked Feb 26 '13 22:02

Ian


2 Answers

  1. In Team Explorer, view builds (double-click the name of your build)
  2. Find and view completed build result (double-click to open).
  3. Click the "view log" link at very top.
  4. Scroll down to section for "Run MSTest for Metadata File"

At end of section, you'll see detail like below which shows location of the .trx (test result file):

Results file:  C:\Source\TestResults\tfsbuild_PMBUILD7 2013-08-05 08_32_02_Any CPU_Release.trx Test Settings: Default Test Settings

Waiting to publish...
 Publishing results of test run tfsbuild@PMBUILD7
2013-08-05 08:32:02_Any CPU_Release to
http://pmtfs:8080/tfs/DefaultCollection... 
....Publish completed successfully.
like image 76
SlightlyBent Avatar answered Oct 02 '22 03:10

SlightlyBent


It will probably depend on your MSBuild/MSTest settings, especially for a gated build (which might do all kinds of things differently), but hopefully something in the following may at least offer you some clues...

The test results are usually dropped into the server's build folder (not the drop folder, but in the working folder in which the MSBuild process stores and builds all your source code, etc), using datestamped filenames for each of the test runs you have executed.

However it sounds like your folder is empty, which indicates that either you are looking in the wrong place (If you're doing a gated build, it may be that it uses a different working folder than a regular build, possibly alongside the C:\Builds\4 folder), or test results are not being generated (disabled or failing).

I'd try to find the build log as it'll almost certainly tell you what happened to the tests and if/where any results were written.

If you can locate the test results files, then you can usually just double click the main test results file to load the test results into Visual Studio (for display in the test results user interface) - so programatically you should be able to just Process.Start(testResultsFilename) to launch Visual Studio to view the results (as long as VS is installed on the computer you're using your tool on).

like image 34
Jason Williams Avatar answered Oct 02 '22 01:10

Jason Williams