不安装Visual Studio如何使用vstest.console.exe运行C++单元测试

4

我将TestWindow文件夹(C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow)复制到一台未安装Visual Studio的计算机上,并尝试在其中运行vstest.console.exe命令,用于测试一个x64 cpp测试dll。

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

以下是我在事件日志中看到的错误信息。

应用程序:vstest.discoveryengine.exe
框架版本:v4.0.30319
描述:由于未处理的异常,该进程已终止。
异常信息:System.IO.FileNotFoundException
堆栈:
   at Microsoft.VisualStudio.TestPlatform.TestRunnerService.DataCollectors.DataCollectionPluginManager..ctor()
   at Microsoft.VisualStudio.TestPlatform.TestRunnerService.WcfTestRunnerService..ctor(System.Threading.ManualResetEvent)
   at Microsoft.VisualStudio.TestPlatform.TestRunnerService.TestRunnerServiceHost.CreateServiceHost(System.String, System.Threading.ManualResetEvent)
   at Microsoft.VisualStudio.TestPlatform.TestRunnerService.ServiceMain.Main(System.String[])
注意:请勿删除任何HTML标签。
3个回答

3

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

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

0
我找到了一个简单的解决方案:只需在服务器上安装Visual Studio Agents即可。
(在这种情况下,无需复制/粘贴TestWindow文件夹。)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接