Visual Studio Test Explorer中nunit测试的工作目录

时间:2015-09-16 11:01:25

标签: unit-testing visual-studio-2008 nunit

我开始尝试将测试资源管理器与nunit测试适配器一起使用。单元测试我正在运行的测试文件是从测试文件夹加载的,测试文件夹包含特定于特定项目的测试文件。我以前手动运行nunit,我能够为测试指定工作目录,但是我无法看到在使用测试资源管理器时我会如何做到这一点。所以目前我有一些单元测试失败,因为他们无法找到这些测试文件。

我已尝试使用项目宏在代码中定义测试文件将与项目目录相关的位置,但这给了我更多问题。我已经尝试按照accessing-visual-studio-macros-from-source-code将Project $(ProjectDir)宏设置为预处理器定义,但是我使用visual studio 2008中的编译器,所以我得到Warning 21 warning C4129: ')' : unrecognized character escape sequence' from PROJECT_DIRECTORY =" $(ProjectDir)" because the backslashes in the directory structure from $(ProjectDir) or by doing PROJECT_DIRECTORY=LR"|($(ProjectDir))|" I get C2065:' LR' :未声明的标识符,因为LR在C ++ 11之前不存在于C ++中。

1 个答案:

答案 0 :(得分:0)

假设这是C ++ - CLI,您可以detect the assembly使用以下行中的内容并从那里执行相对路径:

Type^ type = SomeClassInYourAssembly::typeid;
Assembly^ containerAssembly = System::Reflection::Assembly::GetAssembly(type);
String^ pathTocontainerAssembly = containerAssembly->Location;