GoogleTest is Google's C++ test framework, combining the former GoogleTest and GoogleMock projects into a single library. It's built for C++ developers who need a structured way to write, organize, and run unit tests, including mocks for interfaces and dependencies. Large projects like Chromium, LLVM, Protocol Buffers, and OpenCV rely on it for their test suites.
GoogleTest fits any C++ codebase that needs structured unit testing, from small libraries to large multi-million-line projects. It's a strong choice when you need mock objects to isolate components, when you're testing code with many input variations (value/type-parameterized tests), or when you need to verify crash/exit behavior with death tests. It integrates well with CI systems and CMake or Bazel builds, and has editor/IDE tooling (VS Code extensions, GUI runners) built around it.
It's not the right fit if you need a lightweight, header-only, dependency-free test setup for a tiny project. It requires linking against a real library and, as of the 1.18.x branch, requires at least C++17, so older C++ codebases stuck on earlier standards will need an older release or a different framework. If your project is not C++ (or C, via limited compatibility), look elsewhere; GoogleTest is not designed for other languages.
GoogleTest is typically built from source and linked into your test binaries. The most common approach with CMake:
git clone https://github.com/google/googletest.git
cd googletest
mkdir build
cd build
cmake ..
make
For use inside another CMake project, GoogleTest is commonly pulled in with FetchContent or add_subdirectory, then linked as gtest, gtest_main, gmock, or gmock_main targets. Check googletest/README.md in the repository for build-system-specific instructions (CMake, Bazel) and platform notes.
Detailed usage, from writing your first test to advanced features, is covered in the GoogleTest User's Guide, with the GoogleTest Primer as the recommended starting point for newcomers.