【发布时间】:2013-05-28 08:10:21
【问题描述】:
我正在使用 MS unit testing framework 来测试我的 C# 库。我必须打开一个使用DeploymentItem attribute 部署的文件。但它没有将文件部署到测试部署目录。
在我的单元测试项目中,我创建了一个文件夹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
}
}
我做错了什么?
【问题讨论】:
标签: c# unit-testing visual-studio-2012 vs-unit-testing-framework deploymentitem