Scott Lawrence
Scott Lawrence

Reputation: 7243

Does Application.ExecutablePath return different values depending on the test runner?

I'm trying to see if there's a way to get a consistent unit test result across multiple test runners. The current situation is that we have a test assembly where 4 of the tests pass if you run them in NUnit GUI, but fail if you run them using TestDriven.NET or the ReSharper test runner. In the cases where these tests are failing (a System.NullReferenceException is thrown), Application.ExecutablePath appears to be returning the test runner's executable instead of the DLL of the test assembly.

Is there a value other than Application.ExecutablePath I should be using (we're currently using it to get access to the values inside the .config file for the DLL)? What is the NUnit GUI doing (or not doing) that causes it to behave correctly while other test runners are failing?

Upvotes: 3

Views: 1387

Answers (1)

Grzenio
Grzenio

Reputation: 36639

You can try using the System.Reflection.Assembly class instead, e.g.

String strPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);

There are a few other methods and properties in this class, so I am sure you will find what you need.

Upvotes: 4

Related Questions