fhn*_*eer 17 c# unit-testing deploymentitem vs-unit-testing-framework visual-studio-2012
我MS unit testing framework
用来测试我的C#库.我必须打开一个我正在部署的文件DeploymentItem attribute
.但它没有将文件部署到Test部署目录.
在我的Unit-test项目中,我TestFile
在这个文件夹中创建了一个文件夹,里面有多个文件,比如a.txt,b.txt.
现在在我的Unit-test类中,我添加了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
}
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
Eri*_*oom 18
我在这个帖子中找到了两个可能的解决方案:
希望这可以帮助.
对于将来的引用,从我注意到使用VS 2015 - 您在部署项属性中指定的路径必须相对于构建输出(调试文件夹).如果您的文件夹结构是"UnitTesting\TestData\Test.xml",则DeploymentItem必须是DeploymentItem("..\..\TestData\Test.xml")在这种情况下,TestData文件夹不需要包含在UnitTesting项目中.
归档时间: |
|
查看次数: |
22922 次 |
最近记录: |