We all know the importance of writing automated tests to cover our code. To make it easier for everyone to write good C++ tests, today we have open-sourced Google C++ Testing Framework (Google Test for short), a library that thousands of Googlers have been using in our C++ programs. Highlights of the project include:
- Google Test is portable: it works on a variety of platforms (Linux, Windows, Mac OS X, and more), with several versions of GCC and MSVC compilers, and with or without exceptions. You can even use it in embedded systems like Windows CE and Symbian. Build tools and test runners for many of these are under active development, with Linux Autotools support already in place.
- It supports both fatal and nonfatal assertions. The test will continue after a nonfatal failure. This allows more problems to be uncovered and fixed in a single edit-compile-test cycle.
- It provides many assertions for common testing needs, and lets you easily define new assertions for less common cases.
- On Linux, you can write death tests to ensure that your code crashes with expected errors.
- Because it's based on the popular xUnit architecture, Google Test is easy to learn if you've used any testing framework in this family before.
It will take you about 10 minutes to learn the basics and get started. Stay tuned to this blog for helpful Google Test information in upcoming Testing on the Toilet episodes.
Please send questions and feedback to firstname.lastname@example.org (the Google Test Discussion Group). See you there!