Some programming languages have a dominant testing framework that nearly all developers use. For C++, however, the landscape is a little bit more wide open. Developers have an array of both open source and proprietary tools to choose from.
For this slide show, we focused on some of the best known and widely used C++ testing tools, like Google Test, Cppunit, and the Boost Test Framework. Each slide has a quick overview of the testing tool’s strengths as well as a link to its Web site for those who want to learn more.
These C++ unit testing frameworks and other tools are among the most popular with developers.
Google developed Google Test for its own internal use, and it has quickly become one of the most popular C++ unit testing frameworks. It’s very easy to use, and it simplifies the process of creating an XML report with the testing results. It’s an open source project hosted at GitHub, and it can be used on Linux, Mac OS X, Windows, and other platforms.
Another popular open source C++ unit test framework, the Boost Test Library was created by several people on the C++ standards committee. It’s popular with developers who use the other Boost libraries. Reviewers say that it has excellent documentation and handles exceptions and crashes very well.
QA Systems Cantata is a paid unit testing tool for C and C++. The company claims that Cantata makes testing faster and less expensive thanks to extensive use of automation. It’s also standards-compliant and includes an Eclipse-based GUI for ease of use.
Like Cantata, Parasoft C/C++test is a proprietary tool that supports both C and C++ testing. A leader in the market since the 1990s, it’s an integrated development testing solution that offers static code analysis, unit testing, code review, coverage analysis and runtime error detection.
Microsoft’s flagship integrated development environment, Visual Studio, offers integrated tools for C++ testing (as well as tools for other languages), and has several plug-ins that extend its features. The Microsoft Developer Network explains in detail how to set up and run unit tests with the IDE.
Based on the well-known JUnit testing framework for Java, Cppunit attempts to duplicate JUnit’s benefits for C++. Its primary advantage is that it feels very familiar for developers who have used JUnit or similar testing tools. On the downside, some reviewers say that it is hard to use and its documentation isn’t as thorough as some other options. It’s available from SourceForge under an open source license.
A newer option for C++ unit testing, Catch stands for “C++ Automated Test Cases in Headers.” It handles tests for Objective-C as well as C++, and it’s available under an open source license. Its primary benefits include fast test setup, ease of use, and detailed reporting.
Designed to be “human-friendly,” Bandit is a modern C++ unit testing framework with support for Lambdas. It’s available under the open source MIT license, and it supports C++11.
Like Cppunit, CppUTest is based on JUnit and its related testing frameworks. It can test both C and C++ code, and it was designed to be simple to use and portable and to support test-driven development.
Short for “Template Unit Test,” TUT is a C++ testing framework designed to be portable and easy to deploy. It integrates with most IDEs, and it is available under an open source license.