Write C++ tests with natural syntax and run microbenchmarks in one go
Writing test names as arbitrary sentences and assertions as standard C++ boolean expressions feels familiar to C++ developers. Catch2 simplifies the process of writing and running these tests, while also providing microbenchmarks and BDD macros as built-in features. The repository is based on C++14 or later, and the v3 version moves away from a single header file structure to compile as a standard library.
v3 Release and Structural Changes
The biggest change with the release of Catch2 v3 is that it is no longer a single header library. Catch2 now functions like a standard library, consisting of multiple header files and a separately compiled implementation. The v3 version is currently under development on the devel branch, and documentation updates are in progress. When migrating from v2 to v3, you should refer to the guidelines and common troubleshooting methods provided in the documentation. Previous major versions can be found on the v2.x branch on GitHub.
Writing Tests and Benchmarks
The core advantage of Catch2 is its simple and natural usage. Test names do not need to be valid identifiers, and assertions look like standard C++ boolean expressions. Sections provide a good way to share setup and teardown code locally within a test. It also supports microbenchmarks as a built-in feature, allowing you to measure function execution time using the BENCHMARK macro. Benchmarks do not run by default, so you must explicitly specify the [!benchmark] tag to execute them.
Documentation Structure and Support Scope
The documentation is composed of three parts: 'Why another C++ test framework?', 'Tutorial - Getting Started', and 'Reference Section - All Details'. Bug reports are handled through the GitHub issue tracker, while discussions and questions are conducted on Discord. You can also check how Catch2 is used in open-source software or commercially. C++11 support is provided on the v2.x branch, and C++03 support is available on the Catch1.x branch.
Pre-Adoption Checks
Catch2 supports C++14, C++17, and later versions, so you must ensure your project's C++ standard version meets this requirement. Since v3 documentation updates are still in progress, it is advisable to consult the latest documentation to identify migration issues in advance. Because the structure has changed from a single header file to a standard library, you may need to adjust compilation methods depending on your build system settings. If you must use C++11 or C++03, consider the v2.x or Catch1.x branches instead of v3.