๐Ÿงช Testing C++ with GoogleTest
Home Chapters Examples Diagrams Bibliography GitHub โ†—
Home / Foundations
Part 1 4 chapters

Foundations

From an empty directory to a running GoogleTest suite: CMake presets, CTest, assertions, and fixtures.

Chapter 2

Why test C++, and the toolchain

What a test actually buys you, and how the build files turn a library and a test file into a running GoogleTest suite: the conanfile, the CMake test target, gtest_discover_tests, and CTest.

25 minRead โ†’
Chapter 3

Your first test

Write a GoogleTest suite from an empty file: the anatomy of a TEST, choosing cases that cover the branches, and how CMake presets, CTest, and gtest_discover_tests run them.

25 minRead โ†’
Chapter 4

Assertions and expectations

The difference between a fatal ASSERT and a non-fatal EXPECT, the assertion vocabulary GoogleTest gives you, and how to organize cases into suites.

25 minRead โ†’
Chapter 5

Fixtures

Share prepared state across a group of tests with TEST_F, SetUp, and a fixture class, and rely on per-test construction and RAII to keep each case isolated.

25 minRead โ†’
โ† Previous part Prerequisites Next part โ†’ Beyond the basics

Testing C++ with GoogleTest

A chaptered, runnable guide to testing modern C++ (C++20/23) with GoogleTest and GoogleMock on Fedora 44, from your first test to concurrency, sanitizers, and CI.

Tutorial

  • Chapters
  • Examples
  • Bibliography

Reference

  • GoogleTest docs โ†—
  • CMake docs โ†—
  • View on GitHub โ†—
  • Issues โ†—
Open source ยท Apache-2.0 (code) / CC BY 4.0 (prose) Last built 2026-11-11