我使用MS unit testing framework
来测试我的C#库。我必须打开一个我正在使用DeploymentItem attribute
进行部署的文件。但它不会将文件部署到Test部署目录。DeploymentItem不部署文件
在我的单元测试项目中,我在这个文件夹中创建了一个文件夹TestFile
有多个文件,可以说a.txt,b.txt。
现在在我的单元测试类中,我添加了DeploymentItem属性。但是文件没有被复制。
这是我的代码。
[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
}
}
我在做什么错了?
感谢您的帮助。我设置了“始终复制”。我已经完成了使用测试设置的部署,这次我正在考虑使用DeplyomentAttribute。 –