Google opened its own C ++ testing framework on Independence Day: googletest http://code.google.com/p/googletest/
The tool is primarily written by zhanyong Wan, a software engineer at the Google Testing Technology Group.
Compared with cppunit, googletest has two features:
1. Easy to use. Writing Test cases does not need to be divided into two parts: Declaration and definition, or you do not need to register test suite yourself.
Cppunit is transplanted from JUnit, while C ++ does not have reflection mechanisms like Java (and annotation, and C # does not.CodeMetadata attribute, So you generally need to register each test case. Although cppunit provides some macros, but according to the C ++ member function definition/Declaration separation principle, adding a test case still has to be changed at both ends.
Google test uses a macro similar to cppunitlite to make writing test case as simple as writing a function.
2. More types and information of assert.
In googletest, you write assert_le (orderamount, allowedamount); it indicates that orderamount is not greater than allowedamount. If this assert fails, the error message contains not only orderamount and allowedamount values, but also "orderamount" and "allowedamount" strings. This is impossible with reflection, and can only be achieved with macros.
Of course, Google test can also perform a "death test" to testProgramThe exit code segment. Googletest can fork () a new process, and then check the exit status of the new process or the cause of death of the new process (such as kill by signal ).
In addition: Google C ++ coding standards: http://code.google.com/p/google-styleguide/