mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-17 11:12:25 +01:00
Added instructions for running tests from the command line
This commit is contained in:
parent
ec0ef84226
commit
32e81790d6
113
docs/vs/VS2010commandline.md
Normal file
113
docs/vs/VS2010commandline.md
Normal file
@ -0,0 +1,113 @@
|
||||
VS2010 supports MSTest from the command line:
|
||||
|
||||
```
|
||||
C:\Projects\VS2010TestProjectExample>"c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" /testcontainer:Debug\DefaultTest.dll
|
||||
Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Loading Debug\DefaultTest.dll...
|
||||
Starting execution...
|
||||
|
||||
Results Top Level Tests
|
||||
------- ---------------
|
||||
Failed UnitTest1.?A0x0bae6f70.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.?A0x0bae6f70.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\VS2010TestProjectExample\TestResults\user_machine 2013-11-18 21_43_26.trx
|
||||
Test Settings: Default Test Settings
|
||||
```
|
||||
which gives the following output in the .trx file:
|
||||
|
||||
```
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<TestRun id="e51ef9c4-994d-430e-ad5f-0d9ae7cfe913" name="Malcolm@MAGNESIUM 2013-11-18 21:43:26" runUser="MAGNESIUM\Malcolm" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
|
||||
<TestSettings name="Default Test Settings" id="2a054e79-81e4-409c-98ab-52ce7c45d869">
|
||||
<Execution>
|
||||
<TestTypeSpecific />
|
||||
<AgentRule name="Execution Agents">
|
||||
</AgentRule>
|
||||
</Execution>
|
||||
<Deployment runDeploymentRoot="Malcolm_MAGNESIUM 2013-11-18 21_43_26" />
|
||||
</TestSettings>
|
||||
<Times creation="2013-11-18T21:43:26.3078000+00:00" queuing="2013-11-18T21:43:27.4898000+00:00" start="2013-11-18T21:43:27.6058000+00:00" finish="2013-11-18T21:43:28.7518000+00:00" />
|
||||
<ResultSummary outcome="Failed">
|
||||
<Counters total="2" executed="2" passed="1" error="0" failed="1" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" />
|
||||
</ResultSummary>
|
||||
<TestDefinitions>
|
||||
<UnitTest name="C_A_T_C_H___M_E_T_H_O_D___10_1" storage="debug\defaulttest.dll" id="af655967-2bb2-3e7d-ea29-dcb935212eee">
|
||||
<Description>My first failing catch test in VS2010</Description>
|
||||
<Execution id="68d93196-6df0-4039-9cdd-18b119757895" />
|
||||
<Properties>
|
||||
<Property>
|
||||
<Key>Description</Key>
|
||||
<Value>My first failing catch test in VS2010</Value>
|
||||
</Property>
|
||||
</Properties>
|
||||
<TestMethod codeBase="C:/Projects/VS2010TestProjectExample/Debug/DefaultTest.DLL" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" className="UnitTest1.?A0x0bae6f70.C_A_T_C_H____T_E_S_T____C_L_A_S_S___10_1, DefaultTest, Version=1.0.5069.27763, Culture=neutral, PublicKeyToken=null" name="C_A_T_C_H___M_E_T_H_O_D___10_1" />
|
||||
</UnitTest>
|
||||
<UnitTest name="C_A_T_C_H___M_E_T_H_O_D___6_0" storage="debug\defaulttest.dll" id="42f20899-dc83-75ef-7fff-7375b45879fe">
|
||||
<Description>My first catch test in VS2010</Description>
|
||||
<Execution id="5e53497d-efab-4d09-8ae5-5235e945126d" />
|
||||
<Properties>
|
||||
<Property>
|
||||
<Key>Description</Key>
|
||||
<Value>My first catch test in VS2010</Value>
|
||||
</Property>
|
||||
</Properties>
|
||||
<TestMethod codeBase="C:/Projects/VS2010TestProjectExample/Debug/DefaultTest.DLL" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" className="UnitTest1.?A0x0bae6f70.C_A_T_C_H____T_E_S_T____C_L_A_S_S___6_0, DefaultTest, Version=1.0.5069.27763, Culture=neutral, PublicKeyToken=null" name="C_A_T_C_H___M_E_T_H_O_D___6_0" />
|
||||
</UnitTest>
|
||||
</TestDefinitions>
|
||||
<TestLists>
|
||||
<TestList name="Results Not in a List" id="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
|
||||
<TestList name="All Loaded Results" id="19431567-8539-422a-85d7-44ee4e166bda" />
|
||||
</TestLists>
|
||||
<TestEntries>
|
||||
<TestEntry testId="af655967-2bb2-3e7d-ea29-dcb935212eee" executionId="68d93196-6df0-4039-9cdd-18b119757895" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
|
||||
<TestEntry testId="42f20899-dc83-75ef-7fff-7375b45879fe" executionId="5e53497d-efab-4d09-8ae5-5235e945126d" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
|
||||
</TestEntries>
|
||||
<Results>
|
||||
<UnitTestResult executionId="68d93196-6df0-4039-9cdd-18b119757895" testId="af655967-2bb2-3e7d-ea29-dcb935212eee" testName="C_A_T_C_H___M_E_T_H_O_D___10_1" computerName="MAGNESIUM" duration="00:00:00.3607175" startTime="2013-11-18T21:43:27.6318000+00:00" endTime="2013-11-18T21:43:28.6548000+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="68d93196-6df0-4039-9cdd-18b119757895">
|
||||
<Output>
|
||||
<StdOut>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Using Catch v1.0 b13 for a managed MSTest project.
|
||||
-------------------------------------------------------------------------------
|
||||
My first failing catch test in VS2010
|
||||
-------------------------------------------------------------------------------
|
||||
UnitTest1.cpp(10)
|
||||
...............................................................................
|
||||
|
||||
UnitTest1.cpp(12): FAILED:
|
||||
REQUIRE( false )
|
||||
|
||||
===============================================================================
|
||||
0 test cases - all failed</StdOut>
|
||||
<ErrorInfo>
|
||||
<Message>Assert.Fail failed. REQUIRE( false ), </Message>
|
||||
<StackTrace> at UnitTest1.?A0x0bae6f70.C_A_T_C_H____T_E_S_T____10_1() in c:\projects\vs2010testprojectexample\vs2010testprojectexample\unittest1.cpp:line 12
|
||||
at Catch.FreeFunctionTestCase.invoke(FreeFunctionTestCase* ) in c:\projects\phil\catch\include\internal\catch_vs_test_registry.hpp:line 32
|
||||
at Catch.TestCase.invoke(TestCase* ) in c:\projects\phil\catch\include\internal\catch_test_case_info.hpp:line 78
|
||||
at Catch.RunContext.runCurrentTest(RunContext* , basic_string<char\,std::char_traits<char>\,std::allocator<char> >* redirectedCout, basic_string<char\,std::char_traits<char>\,std::allocator<char> >* redirectedCerr) in c:\projects\phil\catch\include\internal\catch_runner_impl.hpp:line 282
|
||||
at Catch.RunContext.runTest(RunContext* , Totals* , TestCase* testCase) in c:\projects\phil\catch\include\internal\catch_runner_impl.hpp:line 122
|
||||
at UnitTest1.?A0x0bae6f70.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\vs2010testprojectexample\vs2010testprojectexample\unittest1.cpp:line 10
|
||||
</StackTrace>
|
||||
</ErrorInfo>
|
||||
</Output>
|
||||
</UnitTestResult>
|
||||
<UnitTestResult executionId="5e53497d-efab-4d09-8ae5-5235e945126d" testId="42f20899-dc83-75ef-7fff-7375b45879fe" testName="C_A_T_C_H___M_E_T_H_O_D___6_0" computerName="MAGNESIUM" duration="00:00:00.0318671" startTime="2013-11-18T21:43:28.6618000+00:00" endTime="2013-11-18T21:43:28.6988000+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Passed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="5e53497d-efab-4d09-8ae5-5235e945126d">
|
||||
</UnitTestResult>
|
||||
</Results>
|
||||
</TestRun>
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
|
||||
[Home](../../README.md)
|
@ -45,6 +45,10 @@ Now if you click the link for (in this case) "...unittest1.cpp: line 12" you get
|
||||
|
||||
And that's it!
|
||||
|
||||
## Running tests from the command line
|
||||
|
||||
Tests can also be run from the command line. [For VS2010 see these details](VS2010commandline.md)
|
||||
|
||||
## Creating a Catch console project
|
||||
|
||||
If you want to run Catch normally from the console, just create a new Windows Console app (you will need to turn off Unicode for this!) and add an additional .cpp file for `'main()'`. I usually add a file called main.cpp, like this:
|
||||
|
258
docs/vs/VS2012commandline.md
Normal file
258
docs/vs/VS2012commandline.md
Normal file
@ -0,0 +1,258 @@
|
||||
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:
|
||||
|
||||
```
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<TestRun id="4cd5aa0a-c9ca-49be-b248-d8bdff17734f" name="Malcolm@MAGNESIUM 2013-11-18 21:50:39" runUser="MAGNESIUM\Malcolm" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
|
||||
<TestSettings name="Default Test Settings" id="77f2b0c1-8e12-4f70-8ef1-c7370357d694">
|
||||
<Execution>
|
||||
<TestTypeSpecific />
|
||||
<AgentRule name="Execution Agents">
|
||||
</AgentRule>
|
||||
</Execution>
|
||||
<Deployment runDeploymentRoot="Malcolm_MAGNESIUM 2013-11-18 21_50_39" />
|
||||
</TestSettings>
|
||||
<Times creation="2013-11-18T21:50:39.6398000+00:00" queuing="2013-11-18T21:50:40.5708000+00:00" start="2013-11-18T21:50:40.7648000+00:00" finish="2013-11-18T21:50:42.1828000+00:00" />
|
||||
<ResultSummary outcome="Failed">
|
||||
<Counters total="2" executed="2" passed="1" error="0" failed="1" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" />
|
||||
</ResultSummary>
|
||||
<TestDefinitions>
|
||||
<UnitTest name="C_A_T_C_H___M_E_T_H_O_D___6_0" storage="debug\defaulttest.dll" id="602e9cef-23af-97c5-09fb-9d08a9431a51">
|
||||
<Description>My first catch test in VS2010</Description>
|
||||
<Execution id="a5de9acd-c39a-46ab-8779-df5665bc5de1" />
|
||||
<Properties>
|
||||
<Property>
|
||||
<Key>Description</Key>
|
||||
<Value>My first catch test in VS2010</Value>
|
||||
</Property>
|
||||
</Properties>
|
||||
<TestMethod codeBase="C:/Projects/VS2012ManagedTestExample/Debug/DefaultTest.DLL" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" className="UnitTest1.?A0x066a5656.C_A_T_C_H____T_E_S_T____C_L_A_S_S___6_0, DefaultTest, Version=1.0.5069.28570, Culture=neutral, PublicKeyToken=null" name="C_A_T_C_H___M_E_T_H_O_D___6_0" />
|
||||
</UnitTest>
|
||||
<UnitTest name="C_A_T_C_H___M_E_T_H_O_D___10_1" storage="debug\defaulttest.dll" id="f193e129-90c0-27cd-511d-972d38fc323a">
|
||||
<Description>My first failing catch test in VS2010</Description>
|
||||
<Execution id="f2e6a046-5e7b-4606-97a8-7faac3ff61ed" />
|
||||
<Properties>
|
||||
<Property>
|
||||
<Key>Description</Key>
|
||||
<Value>My first failing catch test in VS2010</Value>
|
||||
</Property>
|
||||
</Properties>
|
||||
<TestMethod codeBase="C:/Projects/VS2012ManagedTestExample/Debug/DefaultTest.DLL" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" className="UnitTest1.?A0x066a5656.C_A_T_C_H____T_E_S_T____C_L_A_S_S___10_1, DefaultTest, Version=1.0.5069.28570, Culture=neutral, PublicKeyToken=null" name="C_A_T_C_H___M_E_T_H_O_D___10_1" />
|
||||
</UnitTest>
|
||||
</TestDefinitions>
|
||||
<TestLists>
|
||||
<TestList name="Results Not in a List" id="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
|
||||
<TestList name="All Loaded Results" id="19431567-8539-422a-85d7-44ee4e166bda" />
|
||||
</TestLists>
|
||||
<TestEntries>
|
||||
<TestEntry testId="f193e129-90c0-27cd-511d-972d38fc323a" executionId="f2e6a046-5e7b-4606-97a8-7faac3ff61ed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
|
||||
<TestEntry testId="602e9cef-23af-97c5-09fb-9d08a9431a51" executionId="a5de9acd-c39a-46ab-8779-df5665bc5de1" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
|
||||
</TestEntries>
|
||||
<Results>
|
||||
<UnitTestResult executionId="f2e6a046-5e7b-4606-97a8-7faac3ff61ed" testId="f193e129-90c0-27cd-511d-972d38fc323a" testName="C_A_T_C_H___M_E_T_H_O_D___10_1" computerName="MAGNESIUM" duration="00:00:00.5287967" startTime="2013-11-18T21:50:40.8238000+00:00" endTime="2013-11-18T21:50:42.0128000+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="f2e6a046-5e7b-4606-97a8-7faac3ff61ed">
|
||||
<Output>
|
||||
<StdOut>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Using Catch v1.0 b13 for a managed MSTest project.
|
||||
-------------------------------------------------------------------------------
|
||||
My first failing catch test in VS2010
|
||||
-------------------------------------------------------------------------------
|
||||
UnitTest.cpp(10)
|
||||
...............................................................................
|
||||
|
||||
UnitTest.cpp(12): FAILED:
|
||||
REQUIRE( false )
|
||||
|
||||
===============================================================================
|
||||
0 test cases - all failed</StdOut>
|
||||
<ErrorInfo>
|
||||
<Message>Assert.Fail failed. REQUIRE( false ), </Message>
|
||||
<StackTrace> at UnitTest1.?A0x066a5656.C_A_T_C_H____T_E_S_T____10_1() in c:\projects\vs2012managedtestexample\vs2012managedtestexample\unittest.cpp:line 12
|
||||
at Catch.FreeFunctionTestCase.invoke(FreeFunctionTestCase* ) in c:\projects\phil\catch\include\internal\catch_vs_test_registry.hpp:line 32
|
||||
at Catch.TestCase.invoke(TestCase* ) in c:\projects\phil\catch\include\internal\catch_test_case_info.hpp:line 78
|
||||
at Catch.RunContext.runCurrentTest(RunContext* , basic_string<char\,std::char_traits<char>\,std::allocator<char> >* redirectedCout, basic_string<char\,std::char_traits<char>\,std::allocator<char> >* redirectedCerr) in c:\projects\phil\catch\include\internal\catch_runner_impl.hpp:line 282
|
||||
at Catch.RunContext.runTest(RunContext* , Totals* , TestCase* testCase) in c:\projects\phil\catch\include\internal\catch_runner_impl.hpp:line 122
|
||||
at 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() in c:\projects\vs2012managedtestexample\vs2012managedtestexample\unittest.cpp:line 10
|
||||
</StackTrace>
|
||||
</ErrorInfo>
|
||||
</Output>
|
||||
</UnitTestResult>
|
||||
<UnitTestResult executionId="a5de9acd-c39a-46ab-8779-df5665bc5de1" testId="602e9cef-23af-97c5-09fb-9d08a9431a51" testName="C_A_T_C_H___M_E_T_H_O_D___6_0" computerName="MAGNESIUM" duration="00:00:00.0298274" startTime="2013-11-18T21:50:42.0248000+00:00" endTime="2013-11-18T21:50:42.0858000+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Passed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="a5de9acd-c39a-46ab-8779-df5665bc5de1">
|
||||
</UnitTestResult>
|
||||
</Results>
|
||||
</TestRun>
|
||||
```
|
||||
|
||||
## 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:
|
||||
|
||||
```
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<TestRun id="350652af-9463-47d9-b232-9c6891ccadb4" name="Malcolm@MAGNESIUM 2013-11-18 21:53:40" runUser="MAGNESIUM\Malcolm" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
|
||||
<Times creation="2013-11-18T21:53:40.9958000+00:00" queuing="2013-11-18T21:53:41.0068000+00:00" start="2013-11-18T21:53:41.0228000+00:00" finish="2013-11-18T21:53:41.1668000+00:00" />
|
||||
<TestSettings name="default" id="f940e3ba-7a6e-4241-82ba-119a71c1bd7f">
|
||||
<Execution>
|
||||
<TestTypeSpecific />
|
||||
</Execution>
|
||||
<Deployment runDeploymentRoot="Malcolm_MAGNESIUM 2013-11-18 21_53_40" />
|
||||
</TestSettings>
|
||||
<Results>
|
||||
<UnitTestResult executionId="a3e41c86-4633-4714-8ccf-e29fabda77b7" testId="b47a1138-752a-f65f-694f-1607b17696e1" testName="C_A_T_C_H___M_E_T_H_O_D___6_0" computerName="MAGNESIUM" duration="00:00:00.0321040" startTime="2013-11-18T21:53:40.0248000+00:00" endTime="2013-11-18T21:53:40.0569040+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Passed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="a3e41c86-4633-4714-8ccf-e29fabda77b7" />
|
||||
<UnitTestResult executionId="4525e3fb-6fa4-4e6a-88a3-57f854d57a20" testId="c5c70289-b8cd-b03e-4930-f1394234ca3e" testName="C_A_T_C_H___M_E_T_H_O_D___10_1" computerName="MAGNESIUM" duration="00:00:00.8082727" startTime="2013-11-18T21:53:40.0828000+00:00" endTime="2013-11-18T21:53:40.8910727+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="4525e3fb-6fa4-4e6a-88a3-57f854d57a20">
|
||||
<Output>
|
||||
<StdOut>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
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</StdOut>
|
||||
<ErrorInfo>
|
||||
<Message>Assert failed. false, . c:\projects\vs2012nativetestexample\vs2012nativetestexample\unittest1.cpp, "My first failing catch test in VS2010" line 12</Message>
|
||||
<StackTrace> 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 10</StackTrace>
|
||||
</ErrorInfo>
|
||||
</Output>
|
||||
</UnitTestResult>
|
||||
</Results>
|
||||
<TestDefinitions>
|
||||
<UnitTest name="C_A_T_C_H___M_E_T_H_O_D___6_0" storage="c:\projects\vs2012nativetestexample\debug\vs2012nativetestexample.dll" id="b47a1138-752a-f65f-694f-1607b17696e1">
|
||||
<Execution id="a3e41c86-4633-4714-8ccf-e29fabda77b7" />
|
||||
<TestMethod codeBase="C:\Projects\VS2012NativeTestExample\debug\VS2012NativeTestExample.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter" className="DefaultClassName" name="C_A_T_C_H___M_E_T_H_O_D___6_0" />
|
||||
</UnitTest>
|
||||
<UnitTest name="C_A_T_C_H___M_E_T_H_O_D___10_1" storage="c:\projects\vs2012nativetestexample\debug\vs2012nativetestexample.dll" id="c5c70289-b8cd-b03e-4930-f1394234ca3e">
|
||||
<Execution id="4525e3fb-6fa4-4e6a-88a3-57f854d57a20" />
|
||||
<TestMethod codeBase="C:\Projects\VS2012NativeTestExample\debug\VS2012NativeTestExample.dll" adapterTypeName="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter" className="DefaultClassName" name="C_A_T_C_H___M_E_T_H_O_D___10_1" />
|
||||
</UnitTest>
|
||||
</TestDefinitions>
|
||||
<TestEntries>
|
||||
<TestEntry testId="b47a1138-752a-f65f-694f-1607b17696e1" executionId="a3e41c86-4633-4714-8ccf-e29fabda77b7" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
|
||||
<TestEntry testId="c5c70289-b8cd-b03e-4930-f1394234ca3e" executionId="4525e3fb-6fa4-4e6a-88a3-57f854d57a20" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
|
||||
</TestEntries>
|
||||
<TestLists>
|
||||
<TestList name="Results Not in a List" id="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
|
||||
<TestList name="All Loaded Results" id="19431567-8539-422a-85d7-44ee4e166bda" />
|
||||
</TestLists>
|
||||
<ResultSummary outcome="Failed">
|
||||
<Counters total="2" executed="2" passed="1" failed="1" error="0" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" />
|
||||
<Output>
|
||||
<StdOut>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
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
|
||||
|
||||
</StdOut>
|
||||
</Output>
|
||||
</ResultSummary>
|
||||
</TestRun>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
[Home](../../README.md)
|
@ -49,6 +49,10 @@ Now if you click the link at the top of the stack trace "...unittest.cpp: line 1
|
||||
|
||||
And that's it!
|
||||
|
||||
## Running tests from the command line
|
||||
|
||||
Tests can also be run from the command line. [For VS2012 see these details](VS2012commandline.md)
|
||||
|
||||
## Creating a Catch console project
|
||||
|
||||
If you want to run Catch normally from the console, just create a new Windows Console app (you will need to turn off Unicode for this!) and add an additional .cpp file for `'main()'`. I usually add a file called main.cpp, like this:
|
||||
|
@ -45,6 +45,10 @@ Now if you click the link at the top of the stack trace "...unittest1.cpp: line
|
||||
|
||||
And that's it!
|
||||
|
||||
## Running tests from the command line
|
||||
|
||||
Tests can also be run from the command line. [For VS2012 see these details](VS2012commandline.md)
|
||||
|
||||
## Creating a Catch console project
|
||||
|
||||
If you want to run Catch normally from the console, just create a new Windows Console app (you will need to turn off Unicode for this!) and add an additional .cpp file for `'main()'`. I usually add a file called main.cpp, like this:
|
||||
|
@ -1,4 +1,4 @@
|
||||
Catch now supports integration with Visual Studio 2010 and 2012. It does this by redefining the macros to use existing VS features; whilst this isn't perfect, it seems to be a workable solution for those people who want to use the VS IDE, or for those who need to provide integration with CI systems that are able to process the test results generated by using MSBuild/test runner???.
|
||||
Catch now supports integration with Visual Studio 2010 and 2012. It does this by redefining the macros to use existing VS features; whilst this isn't perfect, it seems to be a workable solution for those people who want to use the VS IDE, or for those who need to provide integration with CI systems that are able to process the test results generated by using MSBuild/vstest.console.exe.
|
||||
|
||||
What does this mean? It means that (with a little care) you can use the same source code for regular Catch, Managed Catch projects in VS and Native Catch projects in VS2012, and you can run tests, see the results and 'click to go to the error' when a test fails.
|
||||
|
||||
@ -18,6 +18,10 @@ We can do the same for VS2012 - [see this page for instructions on how to do thi
|
||||
...and you'll end up with something like this:
|
||||
![VS2012 failing test example](VS2012failingtest.png)
|
||||
|
||||
# Running tests from the command line
|
||||
|
||||
Tests can also be run from the command line. [For VS2010 see these details](VS2010commandline.md) and [for VS2012 see these](VS2012commandline.md)
|
||||
|
||||
# Differences in behaviour
|
||||
|
||||
There are some minor differences in behaviour between Catch and Visual Studio projects; some are inevitable consequences of the 'run one test at a time' architecture of VS, whilst others are workarounds for 'features' in VS itself:
|
||||
|
Loading…
Reference in New Issue
Block a user