Freigeben über


How to preserve the test results directory?

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.

      <RunSettings>
      <MSTest>
      <DeleteDeploymentDirectoryAfterTestRunIsComplete>true</DeleteDeploymentDirectoryAfterTestRunIsComplete>
      </MSTest>
      </RunSettings>

    • 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>)

Comments

  • Anonymous
    June 16, 2015
    The comment has been removed
  • Anonymous
    June 16, 2015
    Once you use the settings xml, it will make sure that the results directory is not deleted. Now in addition if you can any attach file to your results by doing TestContext.AddResultFile (you can now see these files in trx or in VS as attachments)