11

How can I specify output directory when I create DeploymentItem in testsettings? It is easy when you apply DeploymentItem attribute to method or class (there is a special constructor parameter) but I don't see a way to apply it in testsettings (and even UI doesn't contain anything like this).

Nikita R.
  • 7,245
  • 3
  • 51
  • 62
SiberianGuy
  • 24,674
  • 56
  • 152
  • 266

2 Answers2

18

Try editing the testrunconfig file either from VS or using an XML editor - right-click and choose open with and add a line like this one:

<Deployment>
    <DeploymentItem filename="rootdir\SomeDir\" outputDirectory="SomeDir" />
Dror Helper
  • 30,292
  • 15
  • 80
  • 129
  • I tried. It doesn't work. Files are copied to the root of build folder – SiberianGuy Feb 15 '12 at 09:15
  • Use the OutputDirectory to set where the files are copied to – Dror Helper Feb 15 '12 at 09:20
  • 6
    This should work. The key is the trailing \ -- and -- VS only reads these settings when the solution is loaded, so make the change and then close VS down and then back up again. – bryanbcook Feb 16 '12 at 02:48
  • @bryanbcook, thank you for the hint: I really had to restart Visual Studio – SiberianGuy Feb 16 '12 at 16:25
  • Looks like you might also need to restart VS for these settings to take into effect as described here: http://stackoverflow.com/questions/7791161/test-deploymentitem-outputdirectory-will-be-ignored – Nikita R. Jul 27 '12 at 16:22
  • I couldn't make it work for copying the folder, works only if you specify the files one by one. – Nikita R. Jul 27 '12 at 16:40
2

In visual studio 2010:

  1. Go to Test
  2. Edit Test Settings
  3. .testsettings
  4. Go to Deployment
  5. Add your file 'myfile.txt' via Add File...

Close Visual Studio 2010

Go to your project root directory in windows explorer Open the .testsettings file Locate this line:

<DeploymentItem filename="<somedir>\<otherdir>\myfile.txt" />

change it to the output directory that you want:

<DeploymentItem filename="<somedir>\<otherdir>\myfile.txt" outputDirectory="<otherdir>" />

Start Visual Studio 2010 again :-)

For Visual Studio 2012:

http://msdn.microsoft.com/en-us/library/ee256991.aspx

Unit tests run more slowly if you use a test settings file. We recommend that you do not use a test settings file with unit tests. You can configure unit tests by using the .runsettings file instead. To deploy additional files, use DeploymentItemAttribute.

But web performance and load tests always use a test settings file.

Upgrading from 2010 to 2012: http://msdn.microsoft.com/en-us/library/hh507838.aspx

juFo
  • 17,849
  • 10
  • 105
  • 142