The fastest feature-rich C++11/14/17/20/23 single-header testing framework
The fastest feature-rich C++11/14/17/20/23 single-header testing framework
| master branch | ||
| dev branch |
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. A complete example with a self-registering test that compiles to an executable looks like this:
There are many C++ testing frameworks - Catch, Boost.Test, UnitTest++, cpputest, googletest and others.
The key differences between it and other testing frameworks are that it is light and unintrusive:
DOCTEST_CONFIG_DISABLE identifierdoctest::) & doesn't drag any headers with itThis allows the framework to be used in more ways than any other - tests can be written directly in the production code!
Tests can be a form of documentation and should be able to reside near the production code which they test.
The framework can be used just like any other without mixing production code and tests - check out the features.
doctest is modeled after Catch and some parts of the code have been taken directly - check out the differences.
This table compares doctest / Catch / lest which are all very similar.
Project:
Usage:
main() entry pointIf you find a bug, report it! If you have an idea on how to improve the project, be it anything from better documentation to adding new features, consider preparing a feature proposal. We call it proposal because the word "request" has the wrong intention, no one will auto-magically fix it for you, but the idea can be discussed and accepted or rejected before you implement it. Please make sure to read through the Contributing page before submitting any issue, the triaging procedure is documented there.
Contributions in the form of issues and pull requests are welcome - check out the Contributing page.
The logo is licensed under a Creative Commons Attribution 4.0 International License. Copyright © 2019 area55git
SUBCASE in a loop became quadratic in v2.5.x
Per-test-case shared setup across SUBCASEs
Memory leaks just by including doctest.h
Enhance existing matcher system
Feature request: predicate on CHECK_THROWS
Honor FORCE_COLOR and NO_COLOR environment variables
testing private members - ability to write test cases in class bodies
FAQ item request: Accessing current testcase name
Tried to switch a large project from Catch2 v3 to doctest and I see no perf improvements
VS2026: cl.exe 19.51+ miscompiles calls to CHECK()