【问题标题】:Working directory of nunit tests in Visual Studio Test ExplorerVisual Studio 测试资源管理器中 nunit 测试的工作目录
【发布时间】:2015-09-16 19:08:37
【问题描述】:

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

我尝试使用项目宏在代码中定义测试文件相对于项目目录的位置,但这给我带来了更多问题。我已经尝试根据accessing-visual-studio-macros-from-source-code 将项目 $(ProjectDir) 宏设置为预处理器定义,但是我使用的是 Visual Studio 2008 中的编译器,所以我要么得到 Warning 21 warning C4129: ')' : unrecognized character escape sequence' fromPROJECT_DIRECTORY="$(ProjectDir)"@ 987654323@C2065: 'LR' : undeclared identifier` 因为 LR 在 C++11 之前的 C++ 中不存在。

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-26
      • 1970-01-01
      • 2016-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多