I've been browsing through stackoverflow reading other questions about MSTest and DeploymentItem; I've followed all the advice, but nothing has worked for me. I have a folder called "ImportFiles" in my test project with a file called "contacts.xlsx" which has the property Copy to Output Directory set to Copy always, but the file is not getting copied when I run the test.
Sample code below. Any ideas?
[TestMethod]
[DeploymentItem(@"ImportFiles/contacts.xlsx")]
public void MyTestName()
{
// get the file and use it here
var extensions = new {"xlsx"};
var d = new DirectoryInfo(this.TestContext.TestDeploymentDir);
List<FileInfo> importFiles = d.GetFiles().Where(f => extensions.Any(e => f.Extension.EndsWith(e))).ToList();
}
I've also been monitoring the directories as the test is initializing. Nothing but the dlls config and pdb files are getting copied.