CheckOps
GoogleTest
GoogleTest is Google's BSD-3-Clause C++ test framework, merged with GoogleMock, providing xUnit-style tests, rich assertions, death tests, parameterised and typed tests, and C++ mocking.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
GoogleTest is Google’s C++ test framework. Its repository is a merger of the formerly separate GoogleTest and GoogleMock projects, which the README says were so closely related that it made sense to maintain and release them together. It is licensed BSD-3-Clause and is one of the most widely used C++ testing libraries, with about 39,700 GitHub stars.
The README describes GoogleTest as an xUnit test framework and lists its main capabilities: test discovery, a rich set of assertions, user-defined assertions, death tests, fatal and non-fatal failures, value-parameterised tests, type-parameterised tests, various options for running tests, and XML test report generation. Documentation now lives on GitHub Pages at google.github.io/googletest.
Version 1.18.0 was released on 10 August 2026. GoogleTest follows Google’s “live at head” philosophy: Google itself builds against the latest commit, and the project recommends updating regularly. Each release documents the minimum C++ standard required; recent versions require at least C++17 (see the README for the exact policy for your version).
GoogleMock adds a mocking framework for C++: define a mock class with MOCK_METHOD, set expectations with EXPECT_CALL, and use matchers and actions to describe arguments and return values. That makes it possible to test classes in isolation behind interfaces, which is otherwise awkward in C++.
How it compares: Catch2 and doctest favour a lighter, header-friendly style with natural boolean assertions and sections, while GoogleTest offers a larger, more structured feature set and the most mature C++ mocking library. CppUTest and Unity target embedded C and C++ with smaller footprints. GoogleTest’s CMake integration (FetchContent and gtest_discover_tests) and Bazel support make it easy to add to modern build systems, and IDEs such as CLion, Visual Studio and VS Code recognise its tests.
In the quality loop, GoogleTest covers unit and component tests for C++ libraries and services, and its XML output feeds CI dashboards; coverage is usually collected with gcov or llvm-cov and reported through tools such as gcovr.
The source code is at google/googletest on GitHub under the BSD-3-Clause licence, with about 39,700 stars; the most recent commit was on 11 November 2026.
Its README lists notable users beyond Google’s internal projects: the Chromium projects (behind the Chrome browser and ChromeOS), the LLVM compiler, Protocol Buffers and the OpenCV computer vision library. It also points to related open-source projects, including gtest-parallel, a runner that executes test binaries in parallel, the Qt-based GTest Runner GUI, and a TAP listener that emits Test Anything Protocol output.
Features
- Assertions:
EXPECT_*(non-fatal) andASSERT_*(fatal) macros for equality, comparisons, strings, floating point and exceptions. - Test fixtures:
TEST_FwithSetUpandTearDownfor shared state, plus suite-level setup. - Parameterised tests: Value-parameterised (
TEST_P) and type-parameterised tests run the same logic over many inputs or types. - Death tests: Verify that code aborts or exits as expected under invalid conditions.
- GoogleMock:
MOCK_METHOD,EXPECT_CALL, matchers and actions for C++ test doubles. - Filtering and repetition:
--gtest_filter,--gtest_repeatand--gtest_shufflehelp isolate and flush out flaky tests. - XML and JSON reports: Machine-readable output for CI systems.
- Build integration: CMake and Bazel support, including
gtest_discover_testsfor CTest.
Pros
- Complete package: Tests and mocks from one project and one dependency.
- Battle-tested: Used across Google and much of the C++ industry.
- Free to use: Open source under the BSD-3-Clause licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 11 November 2026.
- Community: About 39,700 GitHub stars.
Cons
- Macro-heavy: Test code relies on macros, which some developers find noisy.
- Build integration effort: Adding it to legacy build systems can take work.
- Live-at-head expectations: Older compilers and C++ standards lose support over time.
- Compile times: Large test suites with many templates and mocks can slow builds.
Usage and Links (Example)
Add GoogleTest with CMake FetchContent:
include(FetchContent)
FetchContent_Declare(googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.18.0.zip)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_executable(price_test price_test.cc)
target_link_libraries(price_test GTest::gtest_main GTest::gmock)
include(GoogleTest)
gtest_discover_tests(price_test)
A test with a fixture and a mock:
#include <gmock/gmock.h>
#include <gtest/gtest.h>
class MockGateway : public Gateway {
public:
MOCK_METHOD(bool, Charge, (const std::string& user, int cents), (override));
};
TEST(CheckoutTest, ChargesTheUser) {
MockGateway gateway;
EXPECT_CALL(gateway, Charge("ana", 4200)).WillOnce(testing::Return(true));
Checkout checkout(&gateway);
EXPECT_TRUE(checkout.Pay("ana", 4200));
}
Run with CTest or directly:
ctest --output-on-failure
./price_test --gtest_filter=CheckoutTest.* --gtest_shuffle
Practical tips:
- Use
EXPECT_*by default so one test reports several failures; useASSERT_*when continuing makes no sense. - Shuffle and repeat in CI occasionally to expose order-dependent tests.
- Keep mocks for true boundaries (I/O, clocks, networks) and test pure logic directly.
Resources:
Pricing
GoogleTest is free and open source under the BSD-3-Clause licence.
Recommended for?
- C++ teams wanting a complete, well-documented test and mock framework.
- Projects using CMake or Bazel, where integration is straightforward.
- Large codebases needing parameterised and typed tests.
- Not a fit for very small embedded targets; consider Unity or CppUTest.
Conclusion
GoogleTest, together with GoogleMock, is the most complete and widely adopted testing toolkit for C++.
Its macros take some getting used to, but its assertions, fixtures, parameterised tests and mocking cover nearly every C++ testing need.
Compare
CheckOps pages that put GoogleTest next to related tools. There is no paid placement on these lists.
Roundups
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with GoogleTest side by side.
CCatch2Catch2 is a BSL-1.0 C++ unit testing framework with natural assertions, free-form test names, sections for shared setup, BDD-style macros and built-in micro-benchmarking.Compare with GoogleTest
Ddoctestdoctest is an MIT-licensed, single-header C++ testing framework that is the fastest feature-rich option in compile times and runtime, letting tests live next to production code and be stripped from release binaries.Compare with GoogleTest
CCppUTestCppUTest is a BSD-3-Clause unit testing and mocking framework for C and C++, popular in embedded development for its small footprint, memory leak detection and CppUMock.Compare with GoogleTest
UUnity Test (C)Unity is an MIT-licensed unit testing framework for C focused on embedded toolchains, consisting of a single C file and two headers, from ThrowTheSwitch.org alongside CMock and Ceedling.Compare with GoogleTest
Ggcovrgcovr is a BSD-3-Clause Python tool that summarises GCC/gcov (and LLVM gcov-compatible) coverage for C and C++, producing text, HTML, Cobertura, JaCoCo, LCOV, SonarQube, Coveralls, JSON, CSV and Markdown reports.Compare with GoogleTest
SSonarQubeModernize your AI workflows with code verification for the agentic era.Compare with GoogleTest