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).
问题:
回答1:
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" />
回答2:
In visual studio 2010:
- Go to Test
- Edit Test Settings
- .testsettings
- Go to Deployment
- 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