DeploymentItem不部署文件 [英] DeploymentItem not deploying files
本文介绍了DeploymentItem不部署文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 MS单元测试框架
测试我的C#库。我要打开这我使用 DeploymentItem属性</ code>部署文件。但它不部署文件添加到测试部署目录。
I am using MS unit testing framework
for testing my C# library. I have to open a file which I'm deploying using DeploymentItem attribute
. But it is not deploying file to the Test deployment directory.
在我的单元测试项目中,我创建了一个文件夹 TESTFILE
此文件夹中有多个文件,可以说A.TXT,b.txt。
In my Unit-test project, I created a folder TestFile
in this folder there are multiple files, lets say a.txt, b.txt.
现在在我的单元测试类,我添加DeploymentItem属性。但文件不被复制。
Now in my Unit-test class I added DeploymentItem attribute. But file is not being copied.
下面是我的代码。
[TestClass]
[DeploymentItem("TestFile")]
public class CustomLibraryTest
{
public TestContext TestContext { get; set; }
[TestMethod]
[DeploymentItem(@"TestFiles\a.txt")] // THis should deploy a.txt to test deployment directory
{
var path = TestContext.TestDeploymentDir + "a.txt";
// Now when I debug this unit-test, and open path in explorer,
// a.txt is not present in "TestResults\Deploy_fhafeez 2013-05-28 13_02_37\Out" folder
}
}
我在做什么错了?
推荐答案
我已经找到的此线程:
- 将复制到输出文件夹你的部署文件的属性设置为一直拷贝 (请参阅使用DeploymentItem属性</A> 问题)
- 选中启用部署中的Local.testsettings文件中设置(请参阅使用DeploymentItem 问题属性)
- Set the "Copy To Output Folder" property of your deployment files to "Copy Always" (see Problems with DeploymentItem attribute)
- Check the "Enable Deployment" setting in the Local.testsettings file (see Problems with DeploymentItem attribute)
希望这有助于。
这篇关于DeploymentItem不部署文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文