Google open-source C ++ unit test framework: googletest

Source: Internet
Author: User
Tags coding standards
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/

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.