C ++ testing framework Selection

Source: Internet
Author: User

C ++ testing framework Selection

(Jinqing's column)


This article summarizes the following in a table: "loading the C ++ unit testing framework jungle"

This article compares various unit test frameworks and adds the Google test not added to the original article.
And added another feature comparison, that is, support for mock objects.


Comparison items:

1. Add new tests to minimize workload

2. Ease of modification and Transplantation

3. Easy to assemble/disassemble the test environment (fixtures)

4. Good control over exceptions and crashes

5. Good assertions

6. Different output modes are supported.

7. Support Test Suite (suites)

8. Support for mock objects

Framework 1. Workload 2. Portability 3. Fixtures 4. Exceptions 5. Assertions 6. Various outputs 7.
Test Suite
8. Mock
Cppunit Multiple Required rtti and STL Support
Supported Good Supported Supported Not Supported
Boost. Test Average Rtti, STL, and boost are required Support
Best support Supported Supported Support
Not Supported
Cppunitlite Less Good No
Not Supported Poor Not Supported No
Not Supported
Nanocppunit Less Windows only Support
Unknown Supported Not Supported Supported Not Supported
Unit ++ Many Average No
Average Floating Point Number is not supported Unknown Support
Not Supported
Cxxtest Less Good Support
Supported Supported Supported Supported Supported
Google test Less Good Support
Supported Good Unknown Supported Not Supported


I like cppunit, boost. Test, cppunitlite, and cxxtest.


Only cxxtest supports mock objects. Mock is critical for unit testing.


Also extract a comment on cxxtest (http://www.cppblog.com/shuiyuan2004/archive/2007/08/29/31105.html



Cxxtest has a low workload to add new tests. It does not need to register test cases. It has good portability and ease of loading and unloading. It also has good ability to control exceptions and crashes. It has good assertions; supports multiple output modes and Test suites.

The biggest advantage: compilation is the test method, and you can double-click the result line to immediately locate the corresponding source code, which is quite attractive. Multiple outputs are supported, and the output results are more detailed. Writing and testing is simple;

Disadvantage: You need to use Perl to perform a grammar scan on the test code to generate executable code. You need to use the MAKEFILE file (not required). It is troublesome to prepare.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.