私はC#ライブラリのテストにMS unit testing framework
を使用しています。 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を使用することを考えていました。 –