I use Microsoft Visual Studio test Tools assembly for unit testing.
And from one of my unit tests, I test a class which loads a text file.
The problem is, at the time the unit test runs, the root directory of becoms:
C:\Users\Foo\Documents\Visual Studio 2010\Projects\MyProject\TestResults\Foo_HisComputer 2012-07-03 13_50_45\Out
And that is why the file is not found.
How can I enforce the unit test runtime to use the main application’s root path but not the TestResults folder which it generates after each Unit Test run?
You can add the text file to the output :
You need to set the text file in the project and copy it to the ouput folder.
Otherwise, maybe this link can help you :
http://msdn.microsoft.com/en-us/library/ms243187.aspx