CppUTest

CppUTest is another C++ unit testing framework that you might choose over Google Test/Google Mock. It offers many comparable features, plus provides a built-in memory leak detector. You can see more examples of CppUTest in Test Driven Development for Embedded C [Gre10] by James Grenning.

Installing CppUTest

(Note: These instructions apply to CppUTest version 3.3. The newest version, 3.4, incorporates a number of changes, but was released just prior to my final deadline for major changes, preventing me from incorporating use of it into this book.)

You can find the project home for CppUTest at http://www.cpputest.org/, and you can find downloads at http://cpputest.github.io/cpputest/. Download the appropriate file and unpack, perhaps into a new directory named pputest within your home directory.

Create a CPPUTEST_HOME environment variable. Here’s an example:

 
export CPPUTEST_HOME=/home/jeff/cpputest

You can build CppUTest using make. You will also need to build CppUTestExt, which provides mocking support.

 
cd $CPPUTEST_HOME
 
./configure
 
make
 
make -f Makefile_CppUTestExt

You can install CppUTest to /usr/local/lib using the command make install.

You can build CppUTest using CMake if you choose.

If you are running Windows, you will also find batch files for Visual Studio 2008 and 2010 that use MSBuild.

Creating a Main for Running CppUTest Tests

Code for the WAV Reader example in this book includes a testmain.cpp file designed for use with CppUTest.

wav/1/testmain.cpp
 
#include "CppUTest/CommandLineTestRunner.h"
 
 
int​ main(​int​ argc, ​char​** argv) {
 
return​ CommandLineTestRunner::RunAllTests(argc, argv);
 
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.52.188