C ++ testing framework Selection
(Jinqing's column)
This article summarizes the following in a table: "loading the C ++ unit testing framework jungle"
Http://gamesfromwithin.com/exploring-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 Holding |
Supported |
Good |
Supported |
Supported |
Not Supported |
Boost. Test |
Average |
Rtti, STL, and boost are required |
Support Holding |
Best support |
Supported |
Supported |
Support Holding |
Not Supported |
Cppunitlite |
Less |
Good |
No Supported |
Not Supported |
Poor |
Not Supported |
No Supported |
Not Supported |
Nanocppunit |
Less |
Windows only |
Support Holding |
Unknown |
Supported |
Not Supported |
Supported |
Not Supported |
Unit ++ |
Many |
Average |
No Supported |
Average |
Floating Point Number is not supported |
Unknown |
Support Holding |
Not Supported |
Cxxtest |
Less |
Good |
Support Holding |
Supported |
Supported |
Supported |
Supported |
Supported |
Google test |
Less |
Good |
Support Holding |
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.