Where to place test files for unit testing

I am writing some unit tests and I need to have access to an external file. I suggested that I could just put the file in my solution, mark it for copying to the output directory, and then access it through the relative path. Unfortunately, it seems that unit tests run in a strange directory.

So, instead of starting from:

[MyUnitTestProjectFolder]\bin\Release 

runs from:

 [MySolution]\\[TheProjectI'mTesting]\TestResults\\[MyUsername]_[MyComputerName] [DateTimeStamp]\Out 

My question is: how do I configure access to external files that I need to use from my unit tests?

Please note: files are not text files. They are a proprietary database format with flat files (created from another application), so preparing these files on the fly during a test run is not possible.

+7
file-io unit-testing visual-studio-2010 mstest
source share
1 answer

You can do this using the test run configurations: Open the Test menu, Edit Test Runs, select the test configuration to edit and select Deploy. Here you can add any additional files you need to deploy.

Alternatively, you can use the DeploymentItem attribute when testing.

I looked at visual studio 2008, but I assume that the same features exist in visual studio 2010.

+15
source share

All Articles