MsTest DeploymentItem OutputDirectory in testsetti

2020-02-13 13:26发布

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

2条回答
▲ chillily
2楼-- · 2020-02-13 13:57

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" />
查看更多
迷人小祖宗
3楼-- · 2020-02-13 14:00

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

查看更多
登录 后发表回答