I ran into this problem when working with Visual Studio 2010. I had a project which had a SQL Server Compact database file (.sdf) which according to the build was to be Copied to the output directory during builds. But the problem was that during my unit testing, this file was not being copied out to the target directory for unit testing and code coverage. Once the test was run, it would fail because the database file could not be found.
To have any ancillary file included in a test output run, one needs to add it to the test deployment. Here are the steps
- In the Solution Items folder of the solution find Local.testsettings file.
- Double click the Local.testsettings file
- Select the Deployment category.
- Choose the file by selecting the Add File button.
- Path to the file.
Done and retest to verify.