dar*_*mos 9 .net vb.net resharper nunit visual-studio-2010
我正在尝试编写集成测试来覆盖我的应用程序的大型重构(我想编写单元测试,但它远不是单元可测试的).我正在使用Visual Studio 2010 SP1,Resharper和NUnit.
我目前的问题是我找不到一致的方法来获取执行程序集的目录; 我自己运行应用程序时或者从Visual Studio调试时尝试使用的两种方法,但是在从NUnit或Resharper运行测试时它们会失败.这是代码(VB.NET):
'Method 1
Core.ConfigFile = My.Application.Info.DirectoryPath + "\" + DRA_CONFIG_FILE
'Method 2
Core.ConfigFile = IO.Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly().Location) + "\" + DRA_CONFIG_FILE
Run Code Online (Sandbox Code Playgroud)
当我使用Resharper调试测试时,我得到这样的东西,有两种方法:
C:\Documents and Settings\Tomas\Local Settings\Temp\0xl3rbd5.4qn\MGClient.Test\assembly\dl3\2a373977\60b182bb_e5c9cc01\DRA.config
Run Code Online (Sandbox Code Playgroud)
(它应该是D:\ SVN.DRA.WorkingCopy\DRA.Test\Integration\MGClient.Test\bin\Debug\DRA.config)
我怎样才能获得正确的路径?
您需要在Resharper中禁用阴影复制:
Visial Studio菜单 - > Resharper - >选项 - >工具 - >单元测试
取消选择正在测试的卷影复制程序集