Google's new C ++ testing framework released

Source: Internet
Author: User
Tags xunit

Google has recently opened up its xunit-Based C ++ unit testing framework. Zhanyong Wan, a project developer, said that thousands of C ++ developers have been using the framework within Google for several years.

According to Google, the main highlights of this release are:

    • Google test is portable: it can be applied on multiple platforms (Linux, windows, Mac OS X, etc.) through GCC and msvc compilers of different versions ). You can even use it in embedded systems such as Windows CE and Symbian. Many platform building tools and test runners are under development, and now they are supported by Linux autotools.
    • Supports fatal and nonfatal assertions. The test will continue after nonfatal fails. This allows you to discover and fix more problems in a single edit-compile-test cycle.
    • Provides many assertions for common test requirements, and you can easily define new assertions for uncommon situations.
    • In Linux, you can write death tests to ensure that yourCodeCrash in case of an expected error.
    • Because the framework is based on the popular xunit architecture, if you have used any of the family's test frameworks before, you can easily master them.

C ++CommunityI always think that their unit test tools are not as good as those in other modern languages such as Java and C #. Many people may ask: "Why should I use another tool? What's special about it ?". In FAQs of its wiki, Googlers tries to answer these questions. They said they did not claim that their tools are better than the existing ones, but simply integrated some of the functions that are helpful to their work. We can see from this site:

We hope this list can help you determine whether Google test is helpful to you:

  • Google test is designed to be portable. It can be executed normally when many STL types (such as STD: string and STD: vector) cannot be compiled. It does not require exceptions or rtti. Therefore, it can run on Linux, Mac OS X, windows, and some embedded operating systems.
  • It turns out that nonfatal assertions (keep CT _ *) can save a lot of time because they allow multiple failures to be reported in a single edit-compile-test cycle.
  • Writing assertions that can generate information is very simple: simply use the stream syntax to append any additional information, such as assert_eq (5, Foo (I )) <"where I =" <I ;. It does not need new macros or special functions.
  • Google test automatically detects your tests. If you want to run the tests, you do not need to list them.
  • No framework can predict all your needs, So Google test provides expect_pred * to easily expand your asserted vocabulary. With good syntax, you can use expect_pred * to easily define your own asserted macro.
  • Death tests is very convenient, it ensures that the appropriate circumstances can trigger your assertions in the product.
  • Scoped_trace helps you understand the context of an internal process or loop.
  • You can use the naming mode to determine which tests to run. This saves a lot of time when you want to quickly reproduce a failure.

Saptarshi purkayastha spent some time investigating the framework and wrote some ideas on its blog. His response was positive.

Another amazing thing about the framework is that it is so easy to learn its basic and advanced features. It is very similar to xunit and has the advantage of competing with cppunit. You can learn the basics and advanced features from here. Predicate assertions may be one of my favorite features. When debugging is troublesomeProgram. There are many other assertions that we have not studied them in depth. But since the first time we saw this framework, many of us have taken it as one of the best testing frameworks...

According to the Wiki, you can view the basic manual to get started with Google test as soon as possible, and then refer to the advanced guide for more information.

You can download the framework from here, try it, and then tell the community what you think!

View Original English text:Announcing: new Google C ++ testing framework

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.