【问题标题】:Running c++ unittest using vstest.console.exe without visual studio installed在未安装 Visual Studio 的情况下使用 vstest.console.exe 运行 c++ unittest
【发布时间】:2023-03-22 15:32:01
【问题描述】:

我将 TestWindow 文件夹 (C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow) 复制到没有安装 Visual Studio 的机器上并尝试运行 vstest。 x64 cpp 测试 dll 上的 console.exe 命令。

vstest.console.exe tests.dll /tests:testmethod1 /platform:x64 /logger:console

这是我在事件日志中看到的错误。

应用程序:vstest.discoveryengine.exe 框架版本:v4.0.30319 说明:进程因未处理的异常而终止。 异常信息:System.IO.FileNotFoundException 堆: 在 Microsoft.VisualStudio.TestPlatform.TestRunnerService.DataCollectors.DataCollectionPluginManager..ctor() 在 Microsoft.VisualStudio.TestPlatform.TestRunnerService.WcfTestRunnerService..ctor(System.Threading.ManualResetEvent) 在 Microsoft.VisualStudio.TestPlatform.TestRunnerService.TestRunnerServiceHost.CreateServiceHost(System.String,System.Threading.ManualResetEvent) 在 Microsoft.VisualStudio.TestPlatform.TestRunnerService.ServiceMain.Main(System.String[])

【问题讨论】:

    标签: unit-testing visual-studio-2013


    【解决方案1】:

    FileNotFoundException 是由于缺少一些必需的程序集。我使用 WinDbg 发现了这些并将它们复制到 TestWindow 文件夹中。

     - Microsoft.VisualStudio.Diagnostics.Measurement.dll
     - Microsoft.VisualStudio.Diagnostics.ServiceModelSink.dll
     - Microsoft.VisualStudio.QualityTools.Common.dll
     - Microsoft.VisualStudio.QualityTools.ExecutionCommon.dll
     - Microsoft.VisualStudio.QualityTools.Resource.dll
     - Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
    

    可以在安装了 Visual Studio 的机器上的 C:\windows\assembly\GAC_MSIL 上找到这些程序集。

    我还注意到,如果我从 vstest.console 命令中删除了 /tests 开关,则不需要这些额外的 dll。

    还将以下 dll 复制到 TestWindow 文件夹(以解决目标机器没有 Visual c++ 运行时的情况)

     - C:\Windows\System32\msvcr120.dll
     - C:\Windows\System32\msvcp120.dll
    

    【讨论】:

      【解决方案2】:

      除了拥有 TestWindow 文件夹和上述 GAC 程序集(确保您的 GAC 程序集版本与您的 Visual Studio 版本相匹配)和 VSC++ 程序集(如果需要)之外,我还需要确保 .NET Framework 的最新版本已安装。我正在使用 VS 2012 vstest.console.exe,并且在安装 .NET Framework 4.5.2 Windows Update 后能够运行帮助菜单。

      【讨论】:

        【解决方案3】:

        我找到了一个简单的解决方案:只需在服务器上安装Visual Studio Agents。

        (在这种情况下,无需复制/粘贴 TestWindow 文件夹。)

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-04-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-02-26
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多