我在MSTest單元測試中使用DeploymentItem
屬性時,無法將XSL文件複製到與測試程序集相同的目錄。我遵循this question的選擇答案,我需要複製的文件將其「複製到輸出目錄」設置爲「始終複製」。當我檢查我的ProjectDir \ bin目錄(目標目錄)時,我想複製的文件確實存在,與DLL和PDB一起。C#DeploymentItem無法爲MSTest單元測試複製文件
我有幾個單元測試有以下設置:
private const string DLL = "Service.dll";
private const string XSL_PATH = "transform.xsl";
[TestInitialize]
public void InitializeTest()
{
Assert.IsTrue(File.Exists(DLL)); // passes
}
[TestMethod]
[DeploymentItem(DLL)]
[DeploymentItem(XSL_PATH)]
public void XmlToResultsTest()
{
Assert.IsTrue(File.Exists(XSL_PATH)); // fails
}
的XSL測試失敗,因爲當我檢查的MSTest的TestResults \ particularTestRun \ Out目錄,我看到的DLL和PDBS,但我的XSL文件不在這裏。我想知道的是爲什麼即使我明確告訴Visual Studio通過DeploymentItem
將其複製到那裏,XSL文件也不會與DLL和PDB一起被複制?
我也有同樣的問題薩拉 - 非常混淆的確實! –