googletest
GoogleTest - Google Testing and Mocking Framework
GoogleTest is Google's C++ testing and mocking framework for writing automated tests that check your code works correctly, with assertion macros, parameterized tests, and mock objects that simulate dependencies.
GoogleTest is Google's C++ testing and mocking framework, providing the tools you need to write and run automated tests for C++ code. It solves the fundamental problem of verifying that your code does what you expect: instead of manually running your program and checking results by eye, you write test cases that automatically check conditions and report pass or fail. GoogleTest has been the standard way to test C++ code at Google, and it is also widely used externally by projects like Chromium, LLVM, Protocol Buffers, and OpenCV.
The framework is based on the xUnit architecture — a family of testing patterns where you organize tests into test cases, and each test makes assertions about your code's behavior. GoogleTest provides a rich set of assertion macros: you can check for equality, inequality, whether an exception was thrown, or even whether a function call causes the program to exit in a specific way (called death tests). It automatically discovers and runs all your tests without you needing to register them manually. It supports parameterized tests, which let you run the same test logic with many different input values, and type-parameterized tests, which run with different data types. The repository also includes GoogleMock, a companion framework for creating mock objects — fake versions of dependencies that let you test code in isolation.
You would use GoogleTest whenever you are writing C++ code and want an automated safety net for your logic: catching regressions, verifying edge cases, and documenting expected behavior through tests. The project requires at least C++17, builds with CMake, and runs on Linux, macOS, and Windows.
Where it fits
- Write automated tests for a C++ library that catch regressions before they reach production.
- Use GoogleMock to create fake versions of database or network dependencies so you can test your code in isolation.
- Run parameterized tests to verify the same logic works correctly across many different input values without duplicating test code.