2012-11-28 46 views
15

我試圖從命令行運行單元測試。我嘗試使用下面的命令使用mstest.exe程序:從命令行運行本機VS2012/C++ 64位單元測試

E:\VS Projects\...\>"C:\Program Files (x86)\Microsoft Visual Studio 11.0\ 
    Common7\IDE\MSTest.exe" /testcontainer:mytest.dll 
    /testsettings:"E:\VS Projects\...\Local.testsettings" 

的MSTEST程序性反應是:

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

Loading E:\VS Projects\...\Local.testsettings... 
Loading mytest.dll... 
mytest.dll 
Unable to load the test container 'mytest.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:///E:\VS Projects\...\mytest.dll' or one of its dependencies. The 
module was expected to contain an assembly manifest. 

Local.testsettings不包括信息,該試驗應在64位運行環境。

我可以猜測,mstest期待程序集而不是原生測試項目,這就是爲什麼它失敗。如果是這樣,我怎麼能從命令行運行原生測試?在另一種情況下,我應該如何配置mstest才能正常工作?

+2

這些測試被執行通過針對32位版本的vstest.executionengine.x86.exe,針對64位版本的vstest.executionengine.exe。 –

+1

您近距離:)我正在搜索的程序是隱藏在C:\ Program Files \ Microsoft Visual Studio 11.0 \ Common7 \ IDE \ CommonExtensions \ Microsoft \ TestWindow中的vstest.console.exe。你可以回答這個問題,我可以接受:) – Spook

回答

20

感謝Hans Passant的指導。

的解決方案是使用:

C:\ Program Files文件(x86)的\微軟的Visual Studio 11.0 \ Common7 \ IDE \ CommonExtensions \微軟\ TestWindow \ vstest.console.exe

+0

vs2015中存在相同的可執行文件(14.0,而不是上面路徑中的11.0) - 謝謝 – Caribou