Reputation: 6535
I am trying to test an application which loads an assembly during processing and parses files using the contained information. The problem is while I have the path from where the assembly should be loaded from, to point to my test projects bin folder, what ends up happening is when the test starts running, it runs from a different location that is dynamically created(I believe) by NUnit. How do I force the test to use the local test projects bin path I have set up?
Using this, I am able to access the execution path below, which is not what I want.
System.IO.Path.GetDirectoryName( _ System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
file:\C:\XXXXDEV\XXXXXXXXXXXXXXXXXXX\TestResults\LX####S1Z 2013-03-15 09_44_19\Out
I would rather it point to the Test Projects own local folder where the dlls that I want loaded are found.
C:\XXXXXXXXX\XXXXXXXXXXXX\XXXXXXXXX.Watcher.Test\bin\Debug\XXXXXXOutputXXXXX.dll
Upvotes: 1
Views: 827
Reputation: 6535
I selected Test(menu) > Edit Test Settings > Local(local.testsettings) to open the test settings window. I then scrolled down to select the Unit Test option to the left of the window. To the right of that, I browsed to select my test projects /bin/Debug folder as the Root folder for the assemblies to be loaded. And then I checked the Use the Load Context for assemblies in the test directory checkbox. Click Apply and then Close. After this, when I run my test, the assemblies loads correctly.
Upvotes: 2