doctest
FreeA lightweight and feature-rich C++98/C++11 single-header testing framework for unit tests and TDD.
About doctest
doctest is a new C++ testing framework designed to be the fastest in both compile times and runtime, significantly outperforming other feature-rich alternatives. It provides a fast, transparent, and flexible test runner with a clean interface. A distinctive feature is the ability to write tests directly in production code, enabling tests to serve as documentation and up-to-date comments. The framework is ultra-light on compile times, produces no warnings even on aggressive warning levels, and can remove all testing-related code from the binary using the DOCTEST_CONFIG_DISABLE identifier. It is thread-safe, has no global namespace pollution, and does not drag any headers with it. Portable C++11 (with a tag for C++98) and over 100 different CI builds ensure reliability.
Key Features
Pros & Cons
- Fastest compile times among comparable C++ testing frameworks
- Lightweight and minimal overhead
- No compiler warnings even on highest warning levels
- Thread-safe - asserts can be used from multiple threads
- Portable across C++11, C++14, C++17, C++20, C++23 and C++98
- Can completely disable testing from the binary for production builds
- Allows tests to be embedded directly in production code
- C++ only - not suitable for non-C++ projects
- Less widespread adoption compared to catch or Google Test
- Requires C++11 or later (C++98 via older tag only)
- May have a learning curve for developers used to other frameworks