On this page
Overview
Catch2 is a C++ testing framework for unit tests with built-in support for simple BDD-style scenarios and micro-benchmarks. Tests use TEST_CASE and normal-looking assertion expressions, while CMake targets and CTest discovery integrate the test executable into common C++ build workflows.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Write tests with normal-looking C++ assertion expressions
TEST_CASE defines a test and REQUIRE evaluates a boolean expression while preserving the original expression and resolved values for failure output.
Share local setup through SECTION and BDD macros
SECTION re-runs a test case through independent branches with fresh setup, and SCENARIO, GIVEN, WHEN, and THEN provide BDD-style aliases over the same mechanism.
Sources: [2]
Use exported CMake targets and automatic CTest discovery
Catch2 exports Catch2::Catch2 and Catch2::Catch2WithMain, and catch_discover_tests can register test cases from the built executable with CTest.
Sources: [3]
Best fit
Before adoption
Version 3 is no longer a single-header library
Catch2 v3 uses multiple headers plus separately compiled implementation. Do not reuse v2 single-header setup instructions; use CMake integration or the v3 amalgamated distribution.
Plan for C++14 or newer and the CMake integration requirements
The repository describes v3 as targeting C++14 and later, while the v3.16.0 top-level build requires CMake 3.16 or newer. Projects still tied to C++11 need to evaluate the v2 line separately.
Official sources
- [1]Catch2 v3.16.0 README(2026-10-03)
- [2]Catch2 v3.16.0 tutorial(2026-10-03)
- [3]Catch2 v3.16.0 CMake integration(2026-10-03)
- [4]Catch2 v3.16.0 CMakeLists(2026-10-03)
- [5]Catch2 v3.16.0 release(2026-10-03)
- [6]catchorg/Catch2 repository(2026-10-03)
- [7]Catch2 Boost Software License 1.0(2026-10-03)
Supplemental curator note
Catch2 keeps assertions close to normal C++ expressions and can reduce ceremony when adding tests. Version 3 is no longer a single-header library, so use current CMake targets or the maintained amalgamated distribution instead of older v2 setup guides.
Try it in 3 steps
- 1
Pin Catch2 v3.16.0 with CMake FetchContent
Declare the release tag in CMakeLists.txt, call
FetchContent_MakeAvailable(Catch2), and link the test target toCatch2::Catch2WithMain.FetchContent_Declare(Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v3.16.0) - 2
Create a minimal TEST_CASE
Save this as
test.cppto exercise a normal C++ boolean expression withREQUIRE.#include <catch2/catch_test_macros.hpp>\nTEST_CASE("addition") { REQUIRE(1 + 1 == 2); } - 3
Build and run through CTest
Configure
include(CTest), add Catch2'sextrasdirectory to CMAKE_MODULE_PATH, includeCatch, and callcatch_discover_tests(tests)first.cmake -S . -B build && cmake --build build && ctest --test-dir build --output-on-failure
Growth
Growth trends · Last 30 days
21,504 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 18
- Open PRs
- 59
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- testing
- test-framework
- tdd
- bdd
- no-dependencies
- framework
- cpp14
- cpp
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Jest45,457 Stars
3 shared tag(s) · 2 shared category(s)
Combine assertions, mocks, watch mode, snapshots, coverage, and worker isolation in one JavaScript test runner
TypeScript - Vitest17,180 Stars
2 shared tag(s) · 2 shared category(s)
reuse Vite transforms and configuration across Node, DOM, and Browser Mode tests
TypeScript - JUnit7,056 Stars
2 shared tag(s) · 2 shared category(s)
Java/JVM testing built on Platform and Jupiter
Java - MockK5,762 Stars
2 shared tag(s) · 2 shared category(s)
mock, stub, and verify Kotlin collaborators with coroutine and Android support
Kotlin - Kotest4,789 Stars
2 shared tag(s) · 2 shared category(s)
combine spec styles, assertions, and property testing across Kotlin projects
Kotlin - WebMock4,049 Stars
2 shared tag(s) · 2 shared category(s)
stub Ruby HTTP requests without real network calls and verify expectations against methods, URIs, headers, and bodies
Ruby
Report incorrect information
Tell us if any listing information is incorrect or outdated.