CheckOps
doctest
doctest 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.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
doctest is a C++ testing framework whose README claims it is by far the fastest feature-rich option both in compile times (by orders of magnitude, with published benchmarks) and at runtime. Its syntax is inspired by Catch2 (TEST_CASE, SUBCASE, CHECK, REQUIRE), but it is designed to be light and unintrusive, so tests can be written directly in production source files, like Python docstrings or Rust #[test] functions.
Key differences listed in the README: it is ultra light to include and to use with thousands of assertions; it produces no warnings even at the most aggressive MSVC, GCC and Clang warning levels; DOCTEST_CONFIG_DISABLE removes everything testing-related from the binary; assertions are thread-safe and can be used outside a testing context as a general-purpose assert library; nothing pollutes the global namespace and it drags in no headers; and it is portable C++11 with over 100 CI builds (tag 1.2.9 supports C++98). Features include subcases, test suites, decorators, parameterised tests via templates, reporters (console, XML, JUnit) and filtering from the command line. Version 2.5.3 was released on 6 July 2026.
The source code is at doctest/doctest on GitHub under the MIT licence, with about 6,900 stars; the most recent commit was on 18 October 2026.
Features
- Very fast compile times: Minimal include and assertion overhead.
- Tests in production code: Compile them out with
DOCTEST_CONFIG_DISABLE. - Catch2-like syntax: TEST_CASE, SUBCASE, CHECK and REQUIRE.
- Warning-free and portable: Clean under strict warnings; C++11.
Pros
- Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 18 October 2026.
- Community: About 6,900 GitHub stars.
Cons
- Fewer extras than Catch2: No built-in benchmarking or matchers on the same scale.
- No mocking: Pair with a mocking library such as trompeloeil or gMock.
Usage and Links (Example)
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest/doctest.h>
int apply(int price, int pct) { return price - price * pct / 100; }
TEST_CASE("discounts") {
CHECK(apply(100, 0) == 100);
SUBCASE("ten percent") { CHECK(apply(100, 10) == 90); }
SUBCASE("full") { REQUIRE(apply(100, 100) == 0); }
}
./tests --test-case="discounts" --reporters=junit --out=report.xml
Resources:
Pricing
doctest is free and open source under the MIT licence.
Recommended for?
- C++ projects sensitive to compile times.
- Teams wanting tests next to the code they test.
Conclusion
doctest is the lightest feature-rich C++ test framework, ideal when build speed and unobtrusiveness matter.
Compare
CheckOps pages that put doctest 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 doctest 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 doctest
GGoogleTestGoogleTest 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.Compare with doctest
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 doctest
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 doctest
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 doctest
SSonarQubeModernize your AI workflows with code verification for the agentic era.Compare with doctest