MsTest DeploymentItem OutputDirectory in testsettings

一个人想着一个人 提交于 2019-12-18 07:41:13

问题


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:

  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



来源:https://stackoverflow.com/questions/9289503/mstest-deploymentitem-outputdirectory-in-testsettings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!