I am using MS Unit Tests in VS2010.
I created a class that reads a file..just a static word list. The file was added to the main project and the test project as content with “Copy always” selected as the build event.
When I run the unit test, however, it looks for the file in the output directory of the unit test. How do you make it look in the bin directory. I don’t want to mess with absolute filepaths just for testing…
Test method RequiredServicesTest.RequiredServices_JamesTest.Number2WordsTest threw exception:
Test method RequiredServicesTest.RequiredServices_JamesTest.Number2WordsTest threw exception:
System.IO.FileNotFoundException: Could not find file E:\scomA3proj\TestResults\James_JAMES-PC 2012-02-24 21_22_17\Out\randomdictionary.txt.
Update: One thing I forgot to mention is that this is a WCF Service Library project.
I try to store my test files as an embedded resource in the test class and extract them to a temporary directory (with auto clean up / delete functions) so I never have to worry about where the files live. It seems to be easier and more stable this way.