Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to place test files for unit testing

I am writing some unit 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

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.

like image 856
KrisTrip Avatar asked Aug 02 '10 16:08

KrisTrip


1 Answers

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.

like image 150
Wim Coenen Avatar answered Sep 22 '22 14:09

Wim Coenen