Unit test framework
doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of magnitude) and runtime compared to other feature-rich alternatives. It brings the ability of compiled languages such as D / Rust / Nim to have tests written directly in the production code thanks to a fast, transparent and flexible test runner with a clean interface. - DOCtest
see also
- C++ TestMate - run unit Test inside VSCode
- Basic C++ unit testing with coverage using Catch2 and Gcov
DOCtest
doctest is modeled after Catch and some parts of the code have been taken directly - feature comparison:
- much faster to compile than catch below
- (+) support meson build system
- (+) subcase test (like catch2 scenarios).
- (+) can be used alongside production code.
- (+) decorators
-
(+) vscode integration through C++ TestMate
- (-) missing Matchers
Catch2
a multi-paradigm test framework for C++. - Catch2 / v2 to v3 / The Coding Nest Command line
- Pros
- Header only
- support Nested initialising section as well as BDD syntax
- default and custom Matchers
- main() code can be customized
- Cons
- slow compilation => see v2 to v3 for improvment
- No Mocks
Google Test
Written on January 26, 2018, Last update on January 6, 2023
c++
test
single-header