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.
我试图看看是否有办法在多个测试运行器之间获得一致的单元测试结果。目前的情况是我们有一个测试程序集,如果你在NUnit GUI中运行它们,其中有4个测试通过,但是如果你使用TestDriven.NET或ReSharper测试运行器运行它们就会失败。在这些测试失败的情况下(抛出System.NullReferenceException),Application.ExecutablePath似乎返回测试运行程序的可执行文件而不是测试程序集的DLL。
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?
是否有我应该使用的Application.ExecutablePath以外的值(我们当前正在使用它来访问DLL的.config文件中的值)?什么是NUnit GUI正在做(或不做)导致它在其他测试运行器失败时正常运行?
1 个解决方案
#1
4
You can try using the System.Reflection.Assembly class instead, e.g.
您可以尝试使用System.Reflection.Assembly类,例如
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.
这个类中还有一些其他方法和属性,所以我相信你会找到你需要的东西。
#1
4
You can try using the System.Reflection.Assembly class instead, e.g.
您可以尝试使用System.Reflection.Assembly类,例如
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.
这个类中还有一些其他方法和属性,所以我相信你会找到你需要的东西。