Chapter 7. CppUnit

Overview

CppUnit is a port of JUnit to C++, and was originally authored by Michael Feathers and Jerome Lacoste. Its basic architecture and usage closely follow the xUnit model. The implementation details differ from JUnit as a result of design choices by CppUnit’s developers and language differences between Java and C++. CppUnit’s implementation makes full use of advanced C++ language features, including templates, abstract classes, nested classes, and the Standard Template Library (STL) It also makes extensive use of C macros, which some consider inelegant and error-prone, but are definitely useful here. CppUnit is designed to be thread-safe.

CppUnit is open source software released under the GNU Lesser General Public License. This license makes the code free for use, modification, and redistribution. For details, refer to http://www.gnu.org.

The CppUnit project is based at http://cppunit.sourceforge.net. The information given here is for CppUnit Version 1.8.0.

Architecture

CppUnit contains 24 ordinary classes, 4 abstract classes, 7 template classes, and several nested classes and helper macros. Everything belongs to the namespace “CppUnit” or one of its subordinate namespaces. The CppUnit namespaces are shown in Figure 7-1.

The CppUnit namespaces
Figure 7-1. The CppUnit namespaces

Most of the code belongs to the main namespace, "CppUnit.” The namespace "Asserter” contains assertion functions ...

Get Unit Test Frameworks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.