繁体   English   中英

Visual Studio测试资源管理器中nunit测试的工作目录

[英]Working directory of nunit tests in Visual Studio Test Explorer

我已经开始尝试将Test Explorer与nunit测试适配器一起使用。 我正在运行的单元测试有一些测试文件是从测试文件夹中加载的,该测试文件夹包含特定于特定项目的测试文件。 以前手动运行nunit可以指定测试的工作目录,但看不到使用测试资源管理器时的操作方式。 因此,目前我有一些单元测试失败,因为它们无法找到这些测试文件。

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

假设这是C ++-CLI,则可以使用以下几行代码检测程序集并从此处进行相对路径:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM