8
votes

I'm seriously annoyed with this .\TestResults and test deployment mess. Now I'm trying to completely turn it off, but nothing works. From here:

Consider running your unit tests directly in the build output directory, so that testing runs more rapidly. This is especially useful on the build server after you have checked in your tests. To do this, add a .runsettings file to your solution, include False, and select the file in the Test, Test Settings menu. The same effect occurs in any test run in which DeploymentItemAttribute is not used at all. However, you cannot avoid using a deployment folder if you are using a .testsettings file, which is required for web and load tests, coded UI tests, and any test in which you deploy an application to remote machines.

  1. I tried to create an empty solution with only C# Unit Test project that contains single unit test file with single line in it: string text = File.ReadAllText("test.txt"); And guess where it looks up this file? C:\Code\TestDeployment\TestResults\iLonely_ILONELY-PC 2013-02-17 13_33_37\Out\test.txt

  2. I tried to add test.runsettings file to the solution, as described here:

      <!-- MSTest adapter -->
      <MSTest>
        <MapInconclusiveToFailed>True</MapInconclusiveToFailed>
        <CaptureTraceOutput>false</CaptureTraceOutput>
        <DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
        <DeploymentEnabled>False</DeploymentEnabled>
      </MSTest>
    

    I selected it through Test -> Test settings -> Select test settings file, ran tests... And the result was the same.

Can anyone explain me how to run tests from Output\bin{Configuration} folder?

IMPORTANT: I don't have a .testsettings file, I don't use DeploymentItem attribute.

2
Any code that loads files with a relative path name is broken. Your test showed you the problem, don't shoot the messenger. - Hans Passant
I wrote this test just to see where it looks up the file and so where it runs the test. So it was supposed to fail. - ptkvsk

2 Answers

2
votes

I figured out that this is a ReSharper issue. When I run test by VS runner, everything works fine, it runs from Output\bin{Configuration}. When I run test by ReSharper runner, it runs from deployment dir no matter what I do. Now, the question is: how to control MSTest deployment for ReSharper test runner?

2
votes

Regarding the followup question of how to control MSTest deployment for ReSharper test runner, I just ran into the same issue and solved it.

By default, it doesn't work, but you can make it work by pointing ReSharper to your .testsettings file according to these directions.