Visual Studio Test Project - Does not copy folder on deployment

一个人想着一个人 提交于 2019-12-01 03:08:33

Use the [DeploymentItem] attribute on the test classes that use it. You can specify a directory:

[TestClass]
[DeploymentItem("blahblah\\myDirectory", "myDirectory")]
public class MyTest
{

}

Note:

  • DeploymentItem is very slow when starting the tests. It seems to copy 2 files per second.
  • You can specify the attribute on a test base class. But it does not always work if you have more than one test project.
  • You can probably specify it on a TestClass that has a method marked with [AssemblyInitialize]. Then you have only to provide it once. Not sure, you have to try.
  • The source directory is relative to the solution location. This is hardly documented.
Jaikishan Jalan

Open the .testsettings file in notepad. Now, you should see that for every folder to copy

<DeploymentItem filename="FolderName\" />

Change this to

<DeploymentItem filename="FolderName\" outputDirectory="FolderName\" /> 

The other option you have is to create another folder beneath the original folder, and then that folder will be deployed to the out directory. For example you can have this structure:

TestFolder/

TestFolder/TestDeployment/

And then in the testrunconfig you still select the TestFolder folder and the TestDeployment folder will be deployed to the out directory.

I just had this problem too today. I solved it by adding a folder called "deployment_files" in the project that contained the required folder. Then I put the required folder into the "deployment_files" folder. THEN, I opened the LocalTestRun.testrunconfig file under the "Solution Items" folder in the Solution Explorer. Went to the "Deployment" panel in the testrunconfig property window. Added the "deployment_files" directory to the deployment and voila. The folder within that was copied to the test results Out folder.

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