我正在编写一个测试代码(我只是一个初学者),我需要在本地框中提供一个文件名。我需要签入此代码以及TFS中的文件,以便当其他人使用最新版本时,他们同时获得两者。
//At my local box
string myFilePath= "D:\BACKUP\samplefile.extension";
对于TFS签到,我提供了以下路径,但失败了
string myFilePath= "$MyProjectServer\SomeFolder\samplefile.extension";
现在我的问题是:
答案 0 :(得分:0)
以下是您可以继续的方式:
Copy to Output Directory: Copy always
。例如,添加test.txt
。因为该文件是项目结构的一部分,所以它将作为所有其他文件在源代码管理下添加。使用单元测试中的[DeploymentItem]
属性指示将使用哪个文件。您还可以将测试文件组织到子文件夹中。
[TestMethod]
[DeploymentItem("test.txt")]
public void Index()
{
// use relative path to read the file
var actual = File.ReadAllText("test.txt");
Assert.AreEqual(actual, "some content");
}
答案 1 :(得分:0)
您的TFS路径string myFilePath= "$MyProjectServer\SomeFolder\samplefile.extension"
格式错误。
itemspec的正确格式为:
string myFilePath= "$/MyProjectServer/SomeFolder/samplefile.extension";
请注意在$
之后添加斜杠以及将反斜杠更改为正斜杠。