Brave Location Mobile Apps and Web Solutions

Copying files needed for Visual Studio 2005 Unit Tests

Originally posted on my old MSDN blog

I'm not 100% convinced that the unit test framework in VS2005 is a step forward from using NUnit.

I don't like the interface (in a shallow way I really like the progress bar of NUnit, and the feeling of well-being it gives when it goes green!), and I really hate the way it creates a new directory of files each time tests are run. I can see how that's useful when you're running functional or acceptance tests, but I run unit tests tens or hundreds of times a day, and the disk space that uses up is crazy.

Anyway, one thing I did learn is how to copy test asset files into the Out directory so it can be referenced by the test code. This foxed me for a while, as not unreasonably you would expect the "Copy To Output Directory" property on the file would do the job. However that will copy to the bin\Debug directory on building, but not copy to the Out directory when the tests are run.

The solution is to add the required file to the test run configuration, which is accessed from the Test -> Edit Test run Configurations -> [your config file] menu, and then on the Deployment tab.

N.B. This blog post has now moved to https://writingontablets.com