In VS 2012, when you are running mstest based tests, then the framework deletes the test results directory when the following condition is met.

  • All the test case passes.
  • There is no attachment which got produced in the test run.
  • The option to preserve the test results directory is turned off (default is off).

This essentially means that if you want to preserve the test results directory for all passing tests, then you should do one of the following: -

  • Turn on the option to preserve attachment. This you can do by following the following steps.
    • Create a run settings xml file named settings.xml with following content.


    • Use the settings.xml in your test run. (For VS, activate the settings file in VSU UI and for command-line specify the settings file in the /settings parameter)
  • Make the framework aware of the log files created during the run by using code like TestContext.AddResultFile (<Full Path to the file>)