![](/img/trans.png)
[英]MSTest with WatiN using DeploymentItem - files not getting copied
[英]DeploymentItem not deploying files
我正在使用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
}
}
我做錯了什么?
我在這個帖子中找到了兩個可能的解決方案:
希望這可以幫助。
對於將來的引用,從我注意到使用VS 2015 - 您在部署項屬性中指定的路徑必須相對於構建輸出(調試文件夾)。 如果您的文件夾結構是“UnitTesting \\ TestData \\ Test.xml”,則DeploymentItem必須是DeploymentItem(“.. \\ .. \\ TestData \\ Test.xml”)在這種情況下,TestData文件夾不需要包含在UnitTesting項目中。
我有一組測試,其中副本用於某些測試但不是最新的,即使DeploymentItem屬性設置完全相同。 在完成其他所有操作后,我在解決方案上做了一個“清潔解決方案”並重新啟動並開始正確復制。 因人而異
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.