测试环境不复制我的文件 [英] Test environment does not copy my files

查看:23
本文介绍了测试环境不复制我的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 VS2010.在我的测试项目中,我有一个名为MessageInstances"的文件夹,该文件夹中有一个子文件夹GET_ACTIVITY",该文件夹内有 xml 文件.

I use VS2010. In my test project I have a folder named "MessageInstances" and in that folder there is a subfolder "GET_ACTIVITY", inside that folder there are xml files.

当我运行测试时,应将这些文件相应地复制到输出程序集目录中,即如果 Out 是复制我的测试项目输出的文件夹,则 Out\MessageInstances\GET_ACTIVITY\ 文件夹应该填满我的 xml 文件.

When I run a test, these files should be copied accordingly to the out assembly dir, i.e. if Out is the folder where my test project output is copied then Out\MessageInstances\GET_ACTIVITY\ folder should be filled with my xml files.

我使用 *.testsettings 文件尝试了不同的设置,尝试从 Resharper 单元测试运行器和 VS' 运行测试,但都没有将文件复制到正确的文件夹中.我也玩过 DeploymentItem 属性,但仍然没有成功.

I tried different settings with *.testsettings file, tried running the test from Resharper unit test runner and from VS', but neither copied the files into the right folder. Also I played with DeploymentItem attribute and still no success.

我还能尝试什么?

推荐答案

DeploymentItem 属性仅在项目的 Build Action 设置为 Content 并且 复制到输出目录设置为如果较新则复制始终复制.此外,如果您的测试使用 testsettings 文件运行,您需要在设置中启用部署.如果您有多个,请确保您正在编辑活动的测试运行配置.

The DeploymentItem attribute will only work if Build Action on the item is set to Content and the Copy to Output Directory is set to Copy if Newer or Copy always. Additionally, if your tests are running with a testsettings file you need to enable Deployment in the settings. Make sure you are editing the active test run config in case you have mutiple.

您的 DeploymentItem 应定义如下:

Your DeploymentItem should be defined as follows:

[DeploymentItem("MessageInstances\\GET_ACTIVITY\\", "MessageInstances\\GET_ACTIVITY")]

或者使用@"代替\\"

Or using '@' instead of '\\'

[DeploymentItem(@"MessageInstances\GET_ACTIVITY\", @"MessageInstances\GET_ACTIVITY")]

即您需要指定输出目录,否则文件将被复制到您的测试运行的 Out 目录中.

i.e. you need to specify the output directory, otherwise the files will be copied to the Out directory of your test run.

这篇关于测试环境不复制我的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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