VS2012 supports MSTest for Managed tests and vstest.console.exe for Native tests.
## Managed Tests
To run managed tests from the command line:
```
C:\Projects\VS2012ManagedTestExample>"c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe" /testcontainer:Debug\DefaultTest.dll
Microsoft (R) Test Execution Command Line Tool Version 11.0.50727.1
Copyright (c) Microsoft Corporation. All rights reserved.
Loading Debug\DefaultTest.dll...
Starting execution...
Results Top Level Tests
------- ---------------
Failed UnitTest1.?A0x066a5656.C_A_T_C_H____T_E_S_T____C_L_A_S_S___10_1.C_A_T_C_H___M_E_T_H_O_D___10_1
Passed UnitTest1.?A0x066a5656.C_A_T_C_H____T_E_S_T____C_L_A_S_S___6_0.C_A_T_C_H___M_E_T_H_O_D___6_0
1/2 test(s) Passed, 1 Failed
Summary
-------
Test Run Failed.
Failed 1
Passed 1
---------
Total 2
Results file: C:\Projects\VS2012ManagedTestExample\TestResults\user_machine 2013-11-18 21_50_39.trx
Test Settings: Default Test Settings
```
which gives the following output in the .trx file:
```
My first catch test in VS2010
Description
My first catch test in VS2010
My first failing catch test in VS2010
Description
My first failing catch test in VS2010
```
## Native Tests
Native have to be run using vstest.console.exe:
```
C:\Projects\VS2012NativeTestExample>"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" /Logger:Trx debug\VS2012NativeTestExample.dll
Microsoft (R) Test Execution Command Line Tool Version 11.0.60315.1
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Information: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using Catch v1.0 b13 for a native MSTest project.
-------------------------------------------------------------------------------
"My first failing catch test in VS2010"
-------------------------------------------------------------------------------
c:\projects\vs2012nativetestexample\vs2012nativetestexample\unittest1.cpp(10)
...............................................................................
c:\projects\vs2012nativetestexample\vs2012nativetestexample\unittest1.cpp(12): FAILED:
REQUIRE( false )
===============================================================================
0 test cases - all failed
Passed C_A_T_C_H___M_E_T_H_O_D___6_0
Failed C_A_T_C_H___M_E_T_H_O_D___10_1
Error Message:
Assert failed. false, . c:\projects\vs2012nativetestexample\vs2012nativetestexample\unittest1.cpp, "My first failing catch test in VS2010" line 12
Stack Trace:
at UnitTest1::C_A_T_C_H____T_E_S_T____10_1() in c:\projects\vs2012nativetestexample\vs2012nativetestexample\unittest1.cpp:line 12
at Catch::FreeFunctionTestCase::invoke() in c:\projects\phil\catch\include\internal\catch_vs_test_registry.hpp:line 32
at Catch::TestCase::invoke() in c:\projects\phil\catch\include\internal\catch_test_case_info.hpp:line 78
at Catch::RunContext::runCurrentTest() in c:\projects\phil\catch\include\internal\catch_runner_impl.hpp:line 274
at Catch::RunContext::runTest() in c:\projects\phil\catch\include\internal\catch_runner_impl.hpp:line 124
at UnitTest1::C_A_T_C_H___N_S_10_1::C_A_T_C_H____T_E_S_T____C_L_A_S_S___10_1::C_A_T_C_H___M_E_T_H_O_D___10_1() in c:\projects\vs2012nativetestexample\vs2012nativetestexample\unittest1.cpp:line 10Standard Output Messages:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using Catch v1.0 b13 for a native MSTest project.
-------------------------------------------------------------------------------
"My first failing catch test in VS2010"
-------------------------------------------------------------------------------
c:\projects\vs2012nativetestexample\vs2012nativetestexample\unittest1.cpp(10)
...............................................................................
c:\projects\vs2012nativetestexample\vs2012nativetestexample\unittest1.cpp(12): FAILED:
REQUIRE( false )
===============================================================================
0 test cases - all failed
Results File: C:\Projects\VS2012NativeTestExample\TestResults\user_machine 2013-11-18 21_53_40.trx
Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.
Test Run Failed.
Test execution time: 1.5498 Seconds
```
which gives results like this in the .trx file:
```
```
---
[Home](../../README.md)