views:

35

answers:

1

I have created a test project to test my WPF project. One of my methods needs to read from a file, which is copied into the bin folder

C:\..\ProjectName\Bin\Debug\

when compiling. The method works fine, but when running the unitTest it searches for the file in

C:\..\ProjectName\TestResult\UserName_computerName-Date\Out\

How can I copy the file to that location when running the unit test?

+3  A: 

Are you using MSTest? If so, try the DeploymentItem attribute with the path to your test file:

[DeploymentItem(@"C:\vsprojects\MyProject\Tests\testdata\XmlContentFileOne.xml")]  
[TestMethod]  
public void MyTest()  
{  
  //test 
}    
marinade
Thanks! For this to work, I had to change Local.testSettings file, and enable the deployment.
eflles