Visual Studio测试项目-部署时不复制文件夹 [英] Visual Studio Test Project - Does not copy folder on deployment

查看:108
本文介绍了Visual Studio测试项目-部署时不复制文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是问题所在:
1.在Visual Studio解决方案中创建一个TestProject.
2.打开.testrunco​​nfig文件,然后在部署"菜单项下,选中启用部署"复选框.
3.现在,单击添加目录..."按钮,然后添加其中包含一些文件的文件夹.
4.运行测试项目(使用虚拟测试).

Here is the problem:
1. Create a TestProject in your Visual Studio solution.
2. Open the .testrunconfig file and under the 'deployment' menu item, select the 'Enable Deployment' checkbox.
3. Now click on 'Add Directory...' button and add a folder which has some files in it.
4. Run the test project (use a dummy test).

好吧,现在去检查TestResults文件夹:您将看到所有文件都直接复制到了顶层(顶层)-文件夹本身没有被复制(文件在其下).这在测试过程中弄乱了我的路径.有人能说出如何复制文件夹而不是仅复制下面的文件吗?

Ok, now go check the TestResults folder: You will see that all the files got directly copied (to the top level)- the folder itself is not copied (with the files under them). This messes up my paths during testing. Can anybody tell how to get the folder copied instead of just the files underneath ?

谢谢.

推荐答案

在使用它的测试类上使用[DeploymentItem]属性.您可以指定目录:

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

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

}

注意:

  • DeploymentItem在启动测试时非常慢.似乎每秒复制2个文件.
  • 您可以在测试基类上指定属性.但是,如果您有多个测试项目,那么它并不总是有效.
  • 您可能可以在具有标记为[AssemblyInitialize]的方法的TestClass上指定它.然后,您只需提供一次即可.不确定,您必须尝试.
  • 源目录相对于解决方案位置.几乎没有记录.
  • 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.

这篇关于Visual Studio测试项目-部署时不复制文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆