googletest (google/googletest)

Searching Database…

What is this?Google's testing and mocking framework for C++, built on the xUnit architecture. It merges the formerly separate GoogleTest and GoogleMock projects, which Google now maintains and releases together.
Is this a tool I run, or a library I link into my code?A framework you link into your C++ code, not a separate tool: tests are written in code, compiled into a test binary, and running that binary executes the suite.
How do I start writing tests with it?Read the GoogleTest Primer in the User's Guide — the team recommends the GitHub Pages docs over the in-repo copies. Build instructions live in googletest/README.md; release 1.18.0 is current.
Is my compiler new enough?It needs a C++17-capable compiler: the 1.18.x branch requires at least C++17. Otherwise you just build it from source per googletest/README.md — no other prerequisites are listed.
Is anything changing soon that might affect my build?One to watch: Google plans to take a dependency on Abseil, flagged as coming soon, so expect the framework to gain that dependency in a future release.
Who is using this in production?Many Google-internal projects, plus the Chromium projects behind Chrome and Chrome OS, the LLVM compiler, Protocol Buffers and the OpenCV library — it is battle-tested at massive scale.
Will it work on my platform?It builds and runs wherever the compilers and platforms in Google's Foundational C++ Support Policy are covered — the policy table lists exactly which compiler, platform and build-tool versions are supported.
What can its assertions check?Equality, inequality, exceptions and more out of the box, and you can define your own assertions for code-specific checks. Failures can be fatal or non-fatal, letting a test keep running after a non-fatal failure.
Can one test run against many inputs or data types?Yes — value-parameterized tests rerun with different input values, and type-parameterized tests run with different data types. Death tests verify that code exits in an expected way, useful for error-handling paths.
Can I run a single test, or everything in parallel?Both: GoogleTest offers options to run individual tests, run them in a specific order, or in parallel. Test discovery is automatic, so there is no manual registration list to maintain.
Are there editor integrations or companion tools?For VS Code there are GoogleTest Adapter and C++ TestMate to view, run and debug tests in a tree. Standalone runners include GTest Runner (Qt5 GUI for Windows and Linux), GoogleTest UI and gtest-parallel.
What are similar projects?testify, mockito, mockery, ava, Catch2, phpunit, msw, yoga
Creator
google
Size
13.9 MB
Stars
39.8K
Age
11y
Commits · 90 Days