Snap! Catch2

The Catch2 logo from the catch2 project.

All of our C++ tests make use of Catch2, which is a  C++ framwork allowing us to very quickly develop unit tests against our code.

We have our own extensions1 in the snapcatch2.hpp file so we can very quickly create new tests with our standard set of command line extensions, verbose sections, etc.

The Ubuntu system is often quite behind with the version of Catch2 (actually, it was not even available on Ubuntu 16.04, which only offers version 1.x) so we decided to create our own package with the latest release.

The original source is available on github.

We just keep a tarball of the latest release and generate a new package with it whenever a new version is available.

You can find our package in our Snap! C++ Laucnhpad project. At time of writing, this is available for Ubuntu 22,04, 23.04, 23.10.



  • Upgraded to the Release 2.9.1 of Catch2.
  • Added the CATCH_REQUIRE_LONG_STRING() macro so long strings can be shown in a way where you can see the difference at once.


  • Upgraded to the Release 2.8.0 of Catch2. This fixes a few problems with CMake.
  • Moved the safe_setenv class to the snapdev library.
  • Added our own snapcatch2.hpp header to include our own common extensions.
  • Added the ExceptionWatcher so we can in one go specify (1) the exception type and (2) the exception message.


  • First version we generated so we can use v2 on 16.04 and 18.04.
  • We still have to convert all of our existing tests to v2, though.
  • 1. Some of which are now in Catch2 itself, such as comparing floating points for near equality instead of exact equality.

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly