Why is my VSTest Runner test results file not being written to where I configured it?
Asked by David Massat:

![VSRunnerConfig.PNG](/t5/image/serverpage/image-id/10855i514D0497BA3BD57E/image-size/large?v=v2&px=999 "VSRunnerConfig.PNG")

|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
| 12-Dec-2017 13:38:33 | Passed ShortLocateCacheCollectionCreateDataRequestTest                                                                                     |
| 12-Dec-2017 13:38:33 | Passed ShortLocateCacheCollectionRequestTest                                                                                               |
| 12-Dec-2017 13:38:33 | Passed ShortLocateCacheCollectionRecoveryTest                                                                                              |
| 12-Dec-2017 13:38:33 | Passed DatabaseHelpersTest                                                                                                                 |
| 12-Dec-2017 13:38:33 | Passed EINT_667_TEST                                                                                                                       |
| 12-Dec-2017 13:38:33 | Results File: C:\\Users\\bambooprod\\AppData\\Local\\Temp\\1513103893152-0\\TestResults\\bambooprod_CHI-BLD-W12-01 2017-12-12 13_38_16.trx |
| 12-Dec-2017 13:38:33 |                                                                                                                                            |
| 12-Dec-2017 13:38:33 | Total tests: 54. Passed: 54. Failed: 0. Skipped: 0.                                                                                        |
| 12-Dec-2017 13:38:33 | Test Run Successful.                                                                                                                       |
| 12-Dec-2017 13:38:33 | Test execution time: 18.8019 Seconds                                                                                                       |
| 12-Dec-2017 13:38:33 | Parsing test results under D:\\agent-home\\xml-data\\build-dir\\TRDSVR-LIN2-JOB1...                                                        |
| 12-Dec-2017 13:38:33 | Failing task since test cases were expected but none were found.                                                                           |
| 12-Dec-2017 13:38:33 | Finished task 'Run unit tests' with result: Failed                                                                                         |

The results file is clearly not what I configured above, any ideas please?


Answers:
author: Alexey Chystoprudov
body: vstest.console.exe doesn't allow to specify output filename so Bamboo executes it at temporary folder and then copies generated \*.trx file to folder specified by user. It's not clear from build logs, but it works like this from source code perspective: [https://bitbucket.org/atlassian/bamboo-dotnet-plugin/src/d2788e3b641ccd5e5895d1adc7f115c1046df5f2/src/main/java/com/atlassian/bamboo/plugin/dotnet/tests/vstest/VSTestRunnerTaskType.java?at=default\&fileviewer=file-view-default](https://bitbucket.org/atlassian/bamboo-dotnet-plugin/src/d2788e3b641ccd5e5895d1adc7f115c1046df5f2/src/main/java/com/atlassian/bamboo/plugin/dotnet/tests/vstest/VSTestRunnerTaskType.java?at=default&fileviewer=file-view-default)

comments: author: Jo Peel
body: According to the --help output on my version of vstest.console.exe you can specify the trx file name with the /logger option:
> --logger\|/logger:\<Logger Uri/FriendlyName\>  
> Specify a logger for test results. For example, to log results into a  
> Visual Studio Test Results File (TRX) use /logger:trx\[;LogFileName=\<Defaults to unique file name\>\]  
> Creates file in TestResults directory with given LogFileName.

So the command line:
> "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\TestAgent\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe" /logger:trx;LogFileName=MyResults.trx org.example.tests\\bin\\Debug\\org.example.tests.dll

Will create output in:
> MyResults.trx

Important: Contary to the help output shown above, if no trx file name is specified none will be created!

Unfortunately the Java code linked to in the post does not seem to allow for a user specified trx file name:

```
command.add("/logger:Trx");
```

My guess is that changing this line to the logical equivalent of the following psudo code

```
command.add("/logger:Trx;<resultFileName>");
```

i.e. adding the string ";\<resultFileName\>" part where a file is specified, or a suitable default if not, would create the desired trx file.

See also: [Microsoft/vstest-docs](https://github.com/Microsoft/vstest-docs/blob/master/docs/report.md#2-trx-logger)


author: Paul Faehrt Bus
body: Update: We found that using the vstest.console.exe installed as part of a Visual Studio install fixed our problems.


author: somethingblue
body: Hi David,

If you take a look at the agent logs what do you see? The directory may not have been able to be created or move the result to the result directory.

Take a look at the logs around 12-Dec-2017 13:38:33 and see if there are any errors related to the directory you specified. Let me know what you find.

Cheers,

Branden