从命令行运行mstest对visual studio 2012本机c ++测试 [英] running mstest from command line against visual studio 2012 native c++ tests

查看:473
本文介绍了从命令行运行mstest对visual studio 2012本机c ++测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Visual Studio 2012解决方案与许多本地c + +测试项目。
我可以在Visual Studio 2012中使用测试资源管理器选项卡正确和成功运行所有这些。



但是,我无法获得测试运行时运行




$ b



code> mstest /testcontainer:PathToTestProject\Win32\Release\testproject.dll

我还需要运行

  mstest /testcontainer:PathToTestProject\x64\Release\testproject.dll 



用于测试64位版本的代码。



当我运行这些命令行时,我收到以下错误消息。


测试执行命令行工具版本11.0.50727.1
版权所有(c)Microsoft Corporation。保留所有权利。



加载PathToTestProject\Win32\Release\testproject.dll ...
PathToTestProject\Win32\Release\testproject。 dll
无法加载测试容器PathToTestProject\Win32\Release\testproject.dll'或其中一个依赖项。如果将测试项目组合件构建为64位组合件,则无法加载。在构建测试项目组合件时,为该平台选择任何CPU。要在64位处理器上以64位模式运行测试,必须在主机选项卡中更改测试设置,以在32位进程中运行测试。错误详细信息:无法加载文件或程序集file:/// c:\PathToTestProject\Win32\Release\testproject.dll'或其一个依赖项。该模块应该包含一个程序集清单。


代码是本地c ++,并且在Win32平台上有两个构建配置,其他在x64平台上。我不能有AnyCPU平台配置。
我在这里缺少了什么能够从命令行运行测试?

解决方案

搜索,我终于发现了一个非常隐藏的msdn文档页面
here ,其中描述了mstest与不同测试项目类型的兼容性。
原来,mstest不兼容本机单元测试(很好的msdn,在一个容易找到的位置记录)。
相反,您需要使用visual studio测试运行(vstest.console.exe)而不是msbuild作为本地单元测试项目。



例如

  vstest.console.exe / Platform:x64 PathToTestProject\x64\Release\ testproject.dll 


I have a Visual Studio 2012 Solution with a number of native c++ test projects. I can run all of these correctly and successfully from within Visual Studio 2012 using the Test Explorer tab.

However, I cannot get the tests to run when running from the command line.

Following the documentation I have been running the following command line

mstest /testcontainer:PathToTestProject\Win32\Release\testproject.dll

I also need to run

mstest /testcontainer:PathToTestProject\x64\Release\testproject.dll

for the testing of the 64bit version of the code.

When I run these command lines I get the following error message.

Microsoft (R) Test Execution Command Line Tool Version 11.0.50727.1 Copyright (c) Microsoft Corporation. All rights reserved.

Loading PathToTestProject\Win32\Release\testproject.dll... PathToTestProject\Win32\Release\testproject.dll Unable to load the test container PathToTestProject\Win32\Release\testproject.dll' or one of its dependencies. If you build your test project assembly as a 64 bit assembly, it cannot be loaded. When you build your test project assembly, select "Any CPU" for the platform. To run your tests in 64 bit mode on a 64 bit processor, you must change your test settings in the Hosts tab to run your tests in a 32 bit process. Error details: Could not load file or assembly 'file:///c:\PathToTestProject\Win32\Release\testproject.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

The code is native c++ and has two build configurations one on Win32 platform, and the other on x64 platform. I cannot have an AnyCPU platform configuration. What am I missing here to be able to run the tests from the command line?

解决方案

After a lot of searching, I finally discovered a very hidden msdn documentation page here which states the compatibility of mstest with different test project types. And it turns out the mstest is not compatible with native unit tests (nice of msdn to document this in an easy to find location). Instead you need to use the visual studio test running (vstest.console.exe) instead of msbuild for native unit test projects.

for example

vstest.console.exe /Platform:x64 PathToTestProject\x64\Release\testproject.dll

这篇关于从命令行运行mstest对visual studio 2012本机c ++测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆