Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running mstest from command line against Visual Studio 2012 native C++ tests

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?

like image 526
Windelinckx Avatar asked Feb 26 '13 10:02

Windelinckx


People also ask

How do I run MSTest from command line?

To access the MSTest tool, add the Visual Studio install directory to the path or open the Visual Studio Group from the Start menu, and then open the Tools section to access the Visual Studio command prompt. Use the command MSTest from the command prompt.

What is the command line tool use in Visual Studio to run tests?

VSTest. Console.exe is the command-line tool to run tests. You can specify several options in any order on the command line.

Does Visual Studio use MSTest or VSTest?

Visual Studio includes the VSTest and MSTest command-line tools for testing purposes. We can use both VSTEST and MSTEST to run automated unit and coded UI tests from a command line. 1.


1 Answers

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 
like image 168
Windelinckx Avatar answered Sep 28 '22 08:09

Windelinckx