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

I am trying to figure out if there is a way to get a consistent unit test result for multiple test runners. The current situation is that we have a test assembly in which 4 tests pass if you run them in the NUnit GUI, but do not run them if you run them using TestDriven.NET or the ReSharper test runner. In cases where these tests fail (a System.NullReferenceException is thrown), Application.ExecutablePath seems to return the test runner executable instead of the test build DLL.

Is there a value other than Application.ExecutablePath that I should use (we are currently using it to access the values ​​inside the .config file for the DLL)? What does the NUnit GUI do (or don't) that forces it to behave correctly while other test runners fail?

+3
source share
1 answer

Instead, you can try using the System.Reflection.Assembly class, for example

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

There are several other methods and properties in this class, so I'm sure you will find what you need.

+4
source

Source: https://habr.com/ru/post/1699360/


All Articles