I have a XML file in my project which is added to the output directory when compiled.
When I was running my unit tests against this, Visual Studio threw me this error saying that it couldn’t find the file!
(click to enlarge)
I was really surprised as my XML file is said to copy to output directory and the test fails saying that there is no such file. Checked my Test Solution’s output directory and found that there is indeed the Templates folder and the XML file.
So, whats the problem? Why is my test failing?
Well, the VSTE has a separate directory where it stores all its test results. The directory can be found in your root directory of your solution under the name TestResults. The TestResults also have various folders for each test run you do. If you refer back to the error image that is attached above, you could get the exact directory name. So, the VSTE did not copy the Templates directory to this ‘dynamic’ (for each test run there will be a directory created : correct me if am wrong here) directory. How do we do this then?
The answer is with the Local Test Run Config’s Deployment settings. You can find the local test run config in your solution browser.
Double click the file to open the properties dialog and go to the Deployment section.
Specifying a file or directory here would be included along with the test results :)
My test doesnt fail now 8)
Another way to do this (if its a single file : if you know how to add for a directory, please do leave your comment :) ) is to specify along with your test method,
public void Test_BuildInputXML()