views:

48

answers:

1

I am writing some units tests and I need to be able to access an external file. I assumed I could just place the file in my solution, mark it to be copied to the output directory, and then access it via a relative path. Unfortunately it seems that unit tests are run in a strange directory.


So, instead of running from:
"[MyUnitTestProjectFolder]\bin\Release"

it runs from:
"[MySolution]\[TheProjectI'mTesting]\TestResults\[MyUsername]_[MyComputerName] [DateTimeStamp]\Out"

So my question is, how do I set up access to external files I need to utilize from my unit tests?

Note, the files aren't text files. They are a proprietary flat-file database format (created from another application), so preparing these files "on the fly" during the test run is not feasible.

+3  A: 

You can do this via test run configurations: Open the Test menu, "Edit Test Run Configurations", choose a test configuration to edit, and select the "Deployment" view. Here you can add any extra files that need to be deployed.

Alternatively, you can use the DeploymentItem attribute on your tests.

I've looked at visual studio 2008, but I assume the same features exists in visual studio 2010.

Wim Coenen
Perfect, thats exactly what I was looking for. Thanks!
KrisTrip