Comparison with other frameworks
This page places µTest++ among the major C and C++ testing frameworks, to help choose a framework for a project: how the checks are written, what happens after a failure, how the tests are registered and reported, what each framework needs from the standard library, and how difficult it is to learn. It also tells the contributors which design choices of µTest++ are deliberate, and which are limitations. The footprint of a minimal test program is measured in Footprint; no timing figures are given, since they depend on the toolchain, the target, and the configuration.
The fatal and non-fatal checks of the same frameworks are compared in the User's Guide; that table is not repeated here.
The frameworks
| Framework | Language | Why it is compared |
|---|---|---|
| Boost UT | C++20 | The closest relative: the function comparators of µTest++ were inspired by it. |
| snitch | C++20 | The closest in purpose: a lightweight C++20 framework for constrained targets, with no heap allocation and no stream library. |
| GoogleTest | C++ (the 1.18.x branch requires C++17) | The most widely used C++ framework, with GoogleMock included. |
| Catch2 | C++ (v3 requires C++14) | Popular, with sections, matchers, and benchmarking. |
| doctest | C++ (C++11 and later) | Light on compile times, with a single header. |
| Boost.Test | C++ | The test library of Boost, with header-only, static, and shared variants. |
| Unity | C | The common baseline for tests on microcontrollers. |
| CppUTest | C++ (for C and C++ code) | The other reference for embedded testing, with built-in leak detection. |
Embedded Unit was not included, and JUnit is not a C++ framework.
Summary matrix
| µTest++ | Boost UT | snitch | GoogleTest | Catch2 | doctest | Boost.Test | Unity | CppUTest | |
|---|---|---|---|---|---|---|---|---|---|
| Checks written as | functions (macro-free) | operators and functions | macros | macros | macros | macros | macros | macros | macros |
| Operands printed on failure | yes | yes | yes | yes | yes | yes | yes | typed macros | typed macros |
| Output reports | human-readable, TAP | console, JUnit, selectable with --reporter, replaceable | console, TeamCity, Catch2 XML, selectable with --reporter, extensible | text, XML | several (including JUnit and JSON) | console, replaceable | human-readable, XML, JUnit | text | text, JUnit, TeamCity, Eclipse |
| Nested test cases | yes | yes (should is an alias of test) | sections | no | sections | subcases | suites | no | no |
| Parametrised tests | test_each() | yes | by type (TEMPLATE_TEST_CASE), no value generators | yes | yes | yes | yes | via the runner generator | no dedicated macro found |
| Built-in mocking | no | no | no | yes (GoogleMock) | no | no | no | no (CMock is separate) | yes (CppUMock) |
| Leak detection | no | no | no (the framework itself does not allocate) | no | no | no | no | optional add-on | built in |
| Builds without exceptions | yes | yes (__cpp_exceptions guards) | yes (SNITCH_WITH_EXCEPTIONS) | yes (GTEST_HAS_EXCEPTIONS) | yes (CATCH_CONFIG_DISABLE_EXCEPTIONS) | yes (DOCTEST_CONFIG_NO_EXCEPTIONS) | not the single-header variant (see Footprint) | not applicable (C) | yes (CPPUTEST_HAVE_EXCEPTIONS) |
| Flash added on Cortex-M3 (Footprint) | 46 KiB | 354 KiB | 476 KiB | 411 KiB | 506 KiB | 388 KiB | 479 KiB | 1.4 KiB | 102 KiB |
| Licence | MIT | Boost 1.0 | Boost 1.0 | BSD-3-Clause | Boost 1.0 | MIT | Boost 1.0 | MIT | BSD-3-Clause |
The entries come from the documentation and from the source code of the frameworks (the repositories at the commits listed in Sources). The exceptions row records that the source has a configuration for disabled exceptions; the footprint programs were built in that configuration for the AArch64 and RISC-V platforms, and all of them built except Boost.Test.
Footprint
The footprint of each framework was measured with the smallest useful
program: one test case with the same two checks (an equality and a condition,
on volatile values, so that they are not evaluated at build time), written
with the API of the framework, in its default configuration. The reference is
an empty program, a main() that only returns; one more program, with a single
printf() call, shows the cost of the formatted output of the C library. The
programs are in
tests/sources/benchmarks/footprint,
and are built by the test platforms of the project.
They were built for the QEMU platforms of the tests, with the µOS++ startup and the semihosting support:
- with the xPack GNU toolchains (
arm-none-eabi-gcc15.2.1,aarch64-none-elf-gcc15.2.1, andriscv-none-elf-gcc15.2.0), in the CMake release configuration (-Os), with-ffunction-sections,-fdata-sections, and--gc-sections, and with the full newlib (not newlib-nano); - with the exceptions enabled on the Cortex-M and Cortex-A15 platforms, and disabled on the AArch64 and RISC-V platforms, where they do not work at run time;
- with the frameworks at the release tags listed in Sources.
The tables give the size of each program, in KiB (1024 bytes), followed, in
parentheses, by the increase over the empty program of the same platform. The
flash is the code and the constants (text) plus the initial values of the
variables (data); the RAM is the statically allocated memory (data plus
bss), without the heap and the stack used at run time.
Flash
| Program | Cortex-M0 | Cortex-M3 | Cortex-M4F | Cortex-M7F | Cortex-M33 | Cortex-A15 (AArch32) | Cortex-A72 (AArch64) | RV32IMAC | RV64IMAFDC |
|---|---|---|---|---|---|---|---|---|---|
| Empty program | 91 | 81 | 81 | 78 | 80 | 84 | 7.6 | 1.6 | 1.7 |
A printf() call | 101 (+9.9) | 90 (+9.0) | 90 (+9.0) | 86 (+8.7) | 89 (+8.9) | 93 (+8.9) | 58 (+50) | 45 (+43) | 36 (+35) |
| µTest++ | 138 (+47) | 127 (+46) | 127 (+46) | 124 (+46) | 127 (+46) | 142 (+58) | 227 (+219) | 184 (+182) | 178 (+176) |
| Boost UT | 458 (+367) | 435 (+354) | 435 (+354) | 431 (+353) | 420 (+340) | 438 (+354) | 753 (+745) | 610 (+609) | 610 (+608) |
| snitch | 569 (+478) | 557 (+476) | 556 (+475) | 553 (+475) | 557 (+477) | 583 (+498) | 964 (+957) | 622 (+621) | 918 (+916) |
| GoogleTest | 516 (+425) | 492 (+411) | 492 (+411) | 488 (+410) | 477 (+397) | 514 (+429) | 820 (+812) | 661 (+660) | 661 (+659) |
| Catch2 | 614 (+522) | 587 (+506) | 588 (+507) | 585 (+508) | 573 (+492) | 642 (+558) | 936 (+929) | 766 (+764) | 770 (+768) |
| doctest | 491 (+400) | 468 (+388) | 469 (+388) | 466 (+389) | 454 (+373) | 481 (+397) | 797 (+789) | 645 (+644) | 645 (+643) |
| Boost.Test | 586 (+495) | 560 (+479) | 560 (+479) | 557 (+479) | 545 (+465) | 609 (+525) | — | — | — |
| Unity | 93 (+1.4) | 82 (+1.4) | 82 (+1.4) | 79 (+1.4) | 82 (+1.4) | 86 (+1.8) | 21 (+13) | 10 (+8.8) | 12 (+10) |
| CppUTest | 194 (+103) | 183 (+102) | 183 (+102) | 180 (+102) | 183 (+103) | 206 (+122) | 265 (+257) | 214 (+213) | 209 (+208) |
RAM
| Program | Cortex-M0 | Cortex-M3 | Cortex-M4F | Cortex-M7F | Cortex-M33 | Cortex-A15 (AArch32) | Cortex-A72 (AArch64) | RV32IMAC | RV64IMAFDC |
|---|---|---|---|---|---|---|---|---|---|
| Empty program | 11 | 11 | 11 | 11 | 12 | 35 | 29 | 8.7 | 9.3 |
A printf() call | 11 (+0) | 11 (+0) | 11 (+0) | 11 (+0) | 12 (+0) | 35 (+0) | 33 (+4.0) | 11 (+2.2) | 13 (+3.6) |
| µTest++ | 12 (+0.5) | 12 (+0.5) | 12 (+0.5) | 12 (+0.5) | 12 (+0.5) | 36 (+0.5) | 34 (+5.0) | 12 (+2.9) | 14 (+4.7) |
| Boost UT | 21 (+9.6) | 21 (+9.6) | 21 (+9.6) | 21 (+9.6) | 21 (+9.6) | 45 (+9.6) | 48 (+18) | 21 (+13) | 28 (+18) |
| snitch | 266 (+255) | 266 (+255) | 266 (+255) | 266 (+255) | 266 (+255) | 290 (+255) | 543 (+513) | 266 (+257) | 522 (+513) |
| GoogleTest | 20 (+8.5) | 20 (+8.5) | 20 (+8.5) | 20 (+8.5) | 20 (+8.5) | 44 (+8.5) | 46 (+16) | 20 (+12) | 26 (+16) |
| Catch2 | 21 (+9.5) | 21 (+9.5) | 21 (+9.5) | 21 (+9.5) | 21 (+9.5) | 45 (+9.5) | 47 (+17) | 22 (+13) | 27 (+18) |
| doctest | 21 (+9.8) | 21 (+9.8) | 21 (+9.8) | 21 (+9.8) | 22 (+9.8) | 45 (+9.8) | 48 (+18) | 22 (+13) | 27 (+18) |
| Boost.Test | 25 (+14) | 25 (+14) | 25 (+14) | 25 (+14) | 26 (+14) | 49 (+14) | — | — | — |
| Unity | 12 (+0.2) | 12 (+0.2) | 12 (+0.2) | 12 (+0.2) | 12 (+0.2) | 35 (+0.2) | 33 (+3.6) | 11 (+2.1) | 13 (+3.4) |
| CppUTest | 14 (+2.6) | 14 (+2.6) | 14 (+2.6) | 14 (+2.6) | 14 (+2.6) | 38 (+2.6) | 37 (+7.3) | 15 (+6.4) | 17 (+7.4) |
Reading the figures
- Compare within a column. On the Arm platforms, the µOS++ startup already
links the formatted output of newlib and the C++ run-time support of the
exceptions, including the demangler of the terminate handler, so the empty
program takes 78 to 91 KiB and the increase is mostly the framework. On the
AArch64 and RISC-V platforms the empty program has none of them (less than
8 KiB), so the increase also includes these libraries, which explains the
larger figures; even the
printf()call adds 35 to 50 KiB there. - µTest++. Of the 46 KiB added on the Cortex-M platforms, the functions of µTest++ take about 23 KiB; the rest are functions of the C and C++ libraries.
- Unity is the smallest, as expected from a C framework with no generic comparisons. CppUTest is the next, at about twice µTest++.
- Boost UT, doctest, GoogleTest, Boost.Test, and Catch2 add 340 to 560 KiB each on the Arm platforms, six to eleven times as much as µTest++.
- snitch keeps the default capacities of its static buffers, which take 255 KiB of initialised data (513 KiB on the 64-bit platforms), in the flash and in the RAM; they can be reduced with its configuration options, and the figures shrink accordingly. With these defaults, its test case also needs more than the 8 KiB stack of the test platforms; on the Cortex-M33, which has a stack limit check, the overflow stops the program, while on the other platforms it goes undetected.
- Boost.Test is the single-header variant. It does not build without
exceptions, since
framework_shutdown_helperusestryandcatchunconditionally, and, where it builds, the program does not complete on the bare-metal platforms. It also needsBOOST_SP_DISABLE_THREADSon the Cortex-M0, which has no atomic instructions. - POSIX stubs. GoogleTest, Catch2, and Boost.Test call functions that a
bare-metal newlib does not have (
getcwd(),mkdir(),_getentropy(), andclock_gettime()); the programs link small stubs, included in the figures. CppUTest, built without exceptions, also needsCPPUTEST_STD_CPP_LIB_DISABLEDandCPPUTEST_MEM_LEAK_DETECTION_DISABLED.
The figures are for a single test case with two checks; the cost of each additional check depends on the types of the operands and on the inlining, and was not measured. The run time was not measured either.
Sizes
The sizes reported by size --format=berkeley, in bytes, for all the
platforms:
The text, data, and bss sizes, in bytes
The code and the constants (text):
| Program | Cortex-M0 | Cortex-M3 | Cortex-M4F | Cortex-M7F | Cortex-M33 | Cortex-A15 (AArch32) | Cortex-A72 (AArch64) | RV32IMAC | RV64IMAFDC |
|---|---|---|---|---|---|---|---|---|---|
| Empty program | 90960 | 80076 | 80388 | 77160 | 79528 | 83860 | 7689 | 1563 | 1671 |
A printf() call | 101108 | 89336 | 89584 | 86020 | 88692 | 93022 | 55556 | 44002 | 34256 |
| µTest++ | 139000 | 127436 | 127656 | 124096 | 126772 | 143424 | 228776 | 186058 | 178858 |
| Boost UT | 464096 | 440072 | 440452 | 436456 | 425024 | 443348 | 764299 | 619751 | 618121 |
| snitch | 320044 | 306864 | 305852 | 302740 | 306952 | 333600 | 462488 | 374446 | 415250 |
| GoogleTest | 523420 | 498780 | 499168 | 494588 | 483700 | 521340 | 833585 | 672095 | 670791 |
| Catch2 | 623544 | 596388 | 596936 | 594556 | 581276 | 652652 | 952923 | 778395 | 781565 |
| doctest | 498536 | 474664 | 475156 | 472760 | 459592 | 488460 | 809674 | 655873 | 654301 |
| Boost.Test | 595160 | 567880 | 568236 | 564632 | 552864 | 618292 | — | — | — |
| Unity | 92404 | 81500 | 81788 | 78560 | 80952 | 85716 | 18804 | 9155 | 9673 |
| CppUTest | 196172 | 184380 | 184808 | 181440 | 184324 | 208124 | 267056 | 217072 | 210958 |
The initial values of the variables (data):
| Program | Cortex-M0 | Cortex-M3 | Cortex-M4F | Cortex-M7F | Cortex-M33 | Cortex-A15 (AArch32) | Cortex-A72 (AArch64) | RV32IMAC | RV64IMAFDC |
|---|---|---|---|---|---|---|---|---|---|
| Empty program | 2404 | 2404 | 2404 | 2404 | 2772 | 2212 | 140 | 32 | 36 |
A printf() call | 2404 | 2404 | 2404 | 2404 | 2772 | 2212 | 3492 | 1880 | 3052 |
| µTest++ | 2528 | 2528 | 2528 | 2528 | 2896 | 2332 | 3708 | 2096 | 3284 |
| Boost UT | 4952 | 4952 | 4952 | 4952 | 5320 | 4760 | 6372 | 5032 | 6364 |
| snitch | 263116 | 263116 | 263116 | 263116 | 263484 | 262920 | 524804 | 262724 | 524460 |
| GoogleTest | 4704 | 4704 | 4704 | 4704 | 5072 | 4512 | 6020 | 4876 | 6068 |
| Catch2 | 4688 | 4688 | 4688 | 4688 | 5056 | 4496 | 6004 | 5692 | 6748 |
| doctest | 4676 | 4676 | 4676 | 4676 | 5044 | 4484 | 5980 | 4896 | 6100 |
| Boost.Test | 5236 | 5236 | 5236 | 5236 | 5604 | 5044 | — | — | — |
| Unity | 2412 | 2412 | 2412 | 2412 | 2780 | 2220 | 2836 | 1456 | 2576 |
| CppUTest | 2712 | 2712 | 2712 | 2712 | 3080 | 2516 | 3828 | 2288 | 3420 |
The variables initialised to zero (bss):
| Program | Cortex-M0 | Cortex-M3 | Cortex-M4F | Cortex-M7F | Cortex-M33 | Cortex-A15 (AArch32) | Cortex-A72 (AArch64) | RV32IMAC | RV64IMAFDC |
|---|---|---|---|---|---|---|---|---|---|
| Empty program | 9344 | 9352 | 9352 | 9352 | 9352 | 33924 | 30008 | 8920 | 9520 |
A printf() call | 9344 | 9352 | 9352 | 9352 | 9352 | 33924 | 30704 | 9304 | 10216 |
| µTest++ | 9728 | 9728 | 9728 | 9728 | 9728 | 34304 | 31524 | 9872 | 11056 |
| Boost UT | 16592 | 16600 | 16600 | 16600 | 16600 | 41176 | 42672 | 16960 | 21992 |
| snitch | 9384 | 9384 | 9384 | 9384 | 9384 | 33960 | 30964 | 9520 | 10504 |
| GoogleTest | 15768 | 15776 | 15776 | 15776 | 15776 | 40352 | 41008 | 16088 | 20328 |
| Catch2 | 16760 | 16760 | 16760 | 16760 | 16760 | 41332 | 42000 | 17080 | 21320 |
| doctest | 17104 | 17112 | 17112 | 17112 | 17112 | 41688 | 42704 | 17424 | 22024 |
| Boost.Test | 20688 | 20696 | 20696 | 20696 | 20696 | 45272 | — | — | — |
| Unity | 9544 | 9552 | 9552 | 9552 | 9552 | 34124 | 30960 | 9648 | 10504 |
| CppUTest | 11672 | 11672 | 11672 | 11672 | 11672 | 36244 | 33844 | 13200 | 13696 |
Framework by framework
Each section below describes how the same checks are written in the framework, how a failed requirement stops the test, how the tests are registered, what the framework needs from the standard library, and how it differs from µTest++.
The reference is a small suite with a failing number check, a failing string check, a test case run for several values, and a failing requirement. This is the µTest++ version; it was compiled and run for this page, with the output of the human-readable reporter:
auto& ts = tr.add_top_suite ("Answer");
ts.test ("Number", [] (auto& t)
{
t.expect (mt::eq (answer (), 43)) << "answer is 43";
}
);
ts.test ("Text", [] (auto& t)
{
t.expect (mt::eq ("abc"sv, "abd"sv));
}
);
ts.test_each ("Sizes", { 1, 16, 512 }, [] (auto& t, int size)
{
t.expect (mt::lt (size, 100));
}
);
ts.test ("Requirement", [] (auto& t)
{
t.require (mt::eq (answer (), 43));
t.expect (true) << "not reached";
});
• Number
✗ answer is 43 FAILED (mtp.cpp:12, 42 == 43)
✗ Number - FAILED (0 checks passed, 1 failed)
• Text
✗ FAILED (mtp.cpp:15, "abc" == "abd")
✗ Text - FAILED (0 checks passed, 1 failed)
✓ Sizes (1) - passed (1 check)
✓ Sizes (16) - passed (1 check)
• Sizes (512)
✗ FAILED (mtp.cpp:18, 512 < 100)
✗ Sizes (512) - FAILED (0 checks passed, 1 failed)
• Requirement
✗ FAILED (mtp.cpp:21, 42 == 43) - test case stopped
✗ Requirement - FAILED (0 checks passed, 1 failed)
The snippets for the other frameworks are written from their documentation and headers, and were not compiled for this page; the descriptions of the mechanisms were read in the source code at the commits listed in Sources.
Boost UT
using namespace boost::ut;
"number"_test = [] {
expect (eq (answer (), 43)) << "answer is 43";
};
"sizes"_test
= [] (int size) {
expect (lt (size, 100));
} | std::vector{ 1, 16, 512 };
"requirement"_test = [] {
expect (eq (answer (), 43) >> fatal);
};
- Checks.
expect()accepts the comparators (eq(),lt()) and the operators on typed literals (42_i); the comparators of µTest++ come from here. A failed check prints the operands. - Fatal failure.
fatalmakes the failure throwevents::fatal_assertion, which the runner catches around each test, so only the current test stops, as withrequire()of µTest++; without exceptions, the runner writes the summary and callsstd::abort()(see the User's Guide). - Registration. A test is created by assigning a lambda to the result of the
_testliteral, with no macros and no separate registration step. Parametrised tests useoperator|with a container or a tuple. - Standard library. The header includes
<iostream>,<sstream>,<fstream>,<functional>,<unordered_map>,<string>, and<vector>, among others, and keeps the output in astd::ostringstream. µTest++ does not use the stream library; on the Cortex-M platforms, a minimal Boost UT program adds about 350 KiB of flash, and the same program written with µTest++ about 46 KiB (see Footprint). - Reports. A console reporter and a JUnit reporter, selected with
--reporter; the reporter, runner, and printer can be replaced withcfg<override>. µTest++ has TAP and human-readable reports only. - Other. BDD and Gherkin styles, tags, skipping. The
abortscheck works only on Unix-like systems. - Differences. Same C++20 baseline and same idea of function-like comparators; µTest++ adds suites registered by static objects, a runner with filtering and listing, the TAP report, and the avoidance of the stream library for constrained targets. Boost UT has more styles (BDD, Gherkin) and a replaceable reporter.
snitch
TEST_CASE ("number")
{
CHECK (answer () == 43);
}
TEST_CASE ("text")
{
CHECK (std::string_view ("abc") == std::string_view ("abd"));
}
TEMPLATE_TEST_CASE ("sizes", "[sizes]", short, int, long)
{
CHECK (sizeof (TestType) < 4);
}
TEST_CASE ("requirement")
{
REQUIRE (answer () == 43);
CHECK (true);
}
The reference test case run for the values 1, 16, and 512 has no direct
equivalent: snitch has no GENERATE, so the snippet parametrises by type, which
is what TEMPLATE_TEST_CASE offers.
- Checks. Catch2-style macros:
CHECKandREQUIREwith the natural comparison operators, plus the_FALSE,_THAT(matchers), and_THROWS_ASvariants. The expression is decomposed, so a failed check prints the operands.CONSTEXPR_*andCONSTEVAL_*variants check the expressions at compile time. The messages are limited:INFOandCAPTUREexist, but streaming into them is not supported. - Fatal failure.
REQUIRE,FAIL, andSKIPthrow to abandon the current test case, asrequire()of µTest++ does. When exceptions are disabled (SNITCH_WITH_EXCEPTIONSset to 0, or not available), they callstd::terminate(), so the whole test application stops; the documentation recommends theCHECK*(),FAIL_CHECK(), andSKIP_CHECK()variants and a manual return.require()of µTest++ also aborts the execution when exceptions are disabled (see the User's Guide). - Registration.
TEST_CASEdefines a function and a static variable whose initialiser callssnitch::tests.add()at the static initialisation, into a global registry; the sections nest inside a test case, as in Catch2, and the test case is re-run for each leaf section.TEST_CASE_METHODgives the fixtures, andTEMPLATE_TEST_CASEandTEMPLATE_LIST_TEST_CASEthe parametrisation by type. The main function is generated withSNITCH_DEFINE_MAIN, or written by the application. - Standard library. The headers include
<string_view>,<array>,<optional>,<variant>,<utility>,<type_traits>,<bit>, and a few other light headers, but no stream library, nostd::string, and nostd::vector. The documentation states that the framework does no heap allocation while running the tests, so the tests can monitor the heap use of the tested code. The price is a set of fixed capacities set at build time (SNITCH_MAX_TEST_CASES, 5000 by default, and the maximum lengths of the names, tags, messages, and expressions); longer strings are truncated. - Freestanding. The console (
SNITCH_WITH_STDOUT) and the file output (SNITCH_WITH_STD_FILE_IO) can be disabled, and the application suppliessnitch::cli::console_printand thesnitch::io::file_*functions. - Reports. The default console reporter, plus TeamCity and Catch2 XML,
selected with
--reporter; an application can add its own withREGISTER_REPORTER, which µTest++ does not offer. The verbosity has four levels (quiet,normal,high,full), and the output can go to a file, with the listing of the tests, the tags, and the reporters. There is no TAP reporter. - Other. Tags, matchers, and a library or header-only build
(
snitch_all.hpp). The framework can be compiled out (SNITCH_ENABLE), to keep tests in the same file as the code. The API is a deliberate subset of Catch2, with its own list of differences; theGENERATE,BENCHMARK, and streaming messages are not planned. Test cases are not run in parallel. - Differences. The closest framework to µTest++ in purpose: C++20, built for constrained targets, no stream library, and runs without exceptions. snitch keeps the Catch2 macros and sections, with a stronger and explicit commitment of no heap allocation, fixed capacities, compile-time checks, and replaceable reporters, and adds a build step (a library, or the header-only implementation file). µTest++ has macro-free function comparators, the TAP report, and test cases nested in the code, without the re-running of sections.
GoogleTest
TEST (Answer, Number)
{
EXPECT_EQ (answer (), 43) << "answer is 43";
}
TEST (Answer, Requirement)
{
ASSERT_EQ (answer (), 43);
}
class Sizes : public testing::TestWithParam<int>
{
};
TEST_P (Sizes, Below)
{
EXPECT_LT (GetParam (), 100);
}
INSTANTIATE_TEST_SUITE_P (Values, Sizes, testing::Values (1, 16, 512));
- Checks. Macros of the form
EXPECT_*andASSERT_*for each comparison. The expression is not decomposed: the operands are printed because the macro receives them as arguments. - Fatal failure.
ASSERT_*expands to areturnstatement (GTEST_FATAL_FAILURE_), so it can be used only in functions returningvoid, and, in a helper function, it leaves only the helper.require()of µTest++ stops the whole test case, from any call depth, by throwing, or aborts the execution when exceptions are disabled. - Registration. The
TESTmacros define a class and register it at the static initialisation, withMakeAndRegisterTestInfo(). Fixtures are classes (TEST_F), andTEST_PwithINSTANTIATE_TEST_SUITE_Pgive the parametrised tests. - Standard library.
<ostream>,<sstream>,<string>,<set>,<vector>, and<memory>are included bygtest.h; the framework uses the heap freely. The documentation states C++17 for the 1.18.x branch. - Reports. Console output and XML (
XmlUnitTestResultPrinter); the listeners can be replaced. - Other. GoogleMock is in the same repository; the death tests, the typed tests, and the environment classes have no equivalent in µTest++.
- Differences. GoogleTest is the broadest framework and the one with the largest ecosystem, and it uses the heap and the stream library freely. µTest++ has no mocking, no fixture classes, and a smaller feature set.
Catch2
TEST_CASE ("number")
{
CHECK (answer () == 43);
}
TEST_CASE ("sizes")
{
int size = GENERATE (1, 16, 512);
CHECK (size < 100);
}
TEST_CASE ("requirement")
{
REQUIRE (answer () == 43);
}
- Checks. The macros
CHECK()andREQUIRE()decompose the expression withDecomposerandExprLhs(catch_decomposer.hpp), so the natural operators are used and the operands are reported. µTest++ obtains the same report with function comparators and no macro. - Fatal failure.
REQUIRE()throws aTestFailureException, caught by the run context, which stops the test case. With exceptions disabled (CATCH_CONFIG_DISABLE_EXCEPTIONS) a failedREQUIRE()callsstd::terminate(), as described in the User's Guide. - Registration.
TEST_CASEregisters at the static initialisation.SECTIONre-runs the test case once for each leaf section, a model different from the nested test cases of µTest++, which run once.GENERATEruns the test case for each generated value, andTEST_CASE_METHODprovides fixtures. - Standard library.
<string>,<vector>, and<iosfwd>in the public headers; the library is compiled (a static library target, with the C++14 minimum), and the single-header use is no longer the primary distribution. - Reports. Several reporters, including console, compact, JUnit, JSON, and Automake, and event listeners.
- Other. Matchers, micro benchmarking, and BDD macros.
- Differences. Catch2 offers the richest assertion and generator facilities of the macro frameworks; its features come with a compiled library and a footprint about eleven times that of µTest++ (see Footprint).
doctest
TEST_CASE ("number")
{
CHECK_EQ (answer (), 43);
}
TEST_CASE ("sizes")
{
for (int size : { 1, 16, 512 })
{
SUBCASE (std::to_string (size).c_str ())
{
CHECK_LT (size, 100);
}
}
}
TEST_CASE ("requirement")
{
REQUIRE_EQ (answer (), 43);
}
- Checks.
CHECK()decomposes the expression withExpression_lhs, and theCHECK_EQ()family takes the operands as arguments. The framework has its ownStringclass and includes few standard headers; its documentation claims low compile times, which were not measured here. - Fatal failure.
REQUIRE()callsthrowException(), which throws aTestFailureExceptionand stops the test case. WithDOCTEST_CONFIG_NO_EXCEPTIONS, the fatal macros are rejected at compile time or, with a configuration macro, behave asCHECK()(see the User's Guide). - Registration.
TEST_CASEregisters at the static initialisation.SUBCASEre-runs the test case as the sections of Catch2.TEST_CASE_FIXTUREandTEST_CASE_TEMPLATEprovide fixtures and templates. - Reports.
IReporterandDOCTEST_REGISTER_REPORTERallow custom reporters; the console reporter is the default. - Other. The tests can be written in the production code and removed from
the binary with
DOCTEST_CONFIG_DISABLE. Requires C++11. - Differences. Its documentation emphasises the compile times, which were not measured here; its footprint is close to that of Boost UT (see Footprint). It is a single header with macros; it has subcases, fixtures, and replaceable reporters; µTest++ has the TAP report and the platform support of the µOS++ project.
Boost.Test
BOOST_AUTO_TEST_CASE (number)
{
BOOST_CHECK_EQUAL (answer (), 43);
}
BOOST_AUTO_TEST_CASE (requirement)
{
BOOST_REQUIRE_EQUAL (answer (), 43);
}
- Checks.
BOOST_CHECK*,BOOST_REQUIRE*, andBOOST_TEST(), which decomposes the expression. The family of floating-point, string, and collection comparisons is among the largest. - Fatal failure.
BOOST_REQUIRE*aborts the test case through the execution monitor (execution_monitor.ipp), which catches theexecution_abortedexception; the monitor also reports the signals and the system errors.BOOST_NO_EXCEPTIONSis handled in most of the source, but not inunit_test_main.ipp, so the single-header variant does not build without exceptions (see Footprint). - Registration.
BOOST_AUTO_TEST_CASEandBOOST_FIXTURE_TEST_SUITEregister at the static initialisation; the decorators set the labels, the dependencies, and the expected failures.BOOST_DATA_TEST_CASE(boost/test/data) provides the data-driven tests. - Standard library. The utilities include
<sstream>,<iostream>, and<ostream>; the library is used header-only, static, or shared, and it depends on other Boost libraries. The single-header variant was built for the footprint measurements; the other variants need the rest of Boost. - Reports. Human-readable, XML, and JUnit log and report formats.
- Differences. A large, mature framework with a rich test tree (decorators, dependencies, timeouts); µTest++ has only suites and nested test cases, and it does not depend on Boost.
Unity
void
test_number (void)
{
TEST_ASSERT_EQUAL_INT_MESSAGE (43, answer (), "answer is 43");
}
void
test_text (void)
{
TEST_ASSERT_EQUAL_STRING ("abd", "abc");
}
int
main (void)
{
UNITY_BEGIN ();
RUN_TEST (test_number);
RUN_TEST (test_text);
return UNITY_END ();
}
- Checks. One macro for each type and comparison
(
TEST_ASSERT_EQUAL_INT,TEST_ASSERT_EQUAL_STRING, ...), written in C. The macros are typed, so the operands are printed with the right format, but there is no generic comparison, and no custom types. - Fatal failure. All the assertions are fatal:
TEST_ABORT()callslongjmp()to the frame saved withsetjmp()byTEST_PROTECT(), which does not run the destructors of C++ objects.UNITY_EXCLUDE_SETJMP_Hremoves the dependency. - Registration. None in the core: the tests are listed in
main()withRUN_TEST(), or collected by the Ruby scriptauto/generate_test_runner.rb, which also gives theTEST_CASE,TEST_RANGE, andTEST_MATRIXparametrised tests. - Standard library. The core has no allocation (
mallocis not used inunity.c); the output goes throughUNITY_OUTPUT_CHAR, which defaults toputchar(), and can be redirected. - Reports. Text on the console; the scripts under
auto/convert it. - Other. The
extrasfolder has the fixture, BDD, and memory tracking add-ons; CMock, for mocking, is a separate project. - Differences. Unity is the minimal baseline: a C file and two headers. It tests C well, but it has no generic comparisons, no nested tests, and no suites. µTest++ requires C++20 and a C++ runtime, and gives in exchange the generic checks, the suites, and the TAP reports, for about 46 KiB of flash on the Cortex-M platforms, against 1.4 KiB for Unity (see Footprint).
CppUTest
TEST_GROUP (Answer){};
TEST (Answer, Number)
{
LONGS_EQUAL_TEXT (43, answer (), "answer is 43");
}
TEST (Answer, Text)
{
STRCMP_EQUAL ("abd", "abc");
}
- Checks. Typed macros (
LONGS_EQUAL,STRCMP_EQUAL,CHECK_EQUAL), with no non-fatal variants: a failed check stops the test. - Fatal failure. With exceptions, the failure throws a
CppUTestFailedException(Utest.cpp), caught by the test shell; without them,TestTerminatorWithoutExceptionsis used. - Registration.
TEST_GROUPandTESTdefine a class and a static instance of it, which registers at the static initialisation;setup()andteardown()of the group wrap each test. - Memory.
MemoryLeakDetectorNewMacros.hredefinesnewto pass the file and line, so the leaks are reported with their location; a checkpoint is compared beforesetup()and afterteardown(). µTest++ has no equivalent. - Standard library. The use of the C and C++ libraries is switched by
CPPUTEST_USE_STD_C_LIBandCPPUTEST_USE_STD_CPP_LIB; exceptions and RTTI are detected (CPPUTEST_HAVE_EXCEPTIONS,CPPUTEST_HAVE_RTTI). - Reports. Console, JUnit (
-ojunit), TeamCity, and Eclipse. - Other. CppUMock, for mocks.
- Differences. The other embedded reference. It has mocking, leak detection, and a long record on small targets, with macros and typed checks. µTest++ has generic checks and nested test cases, with C++20 as the price.
Design choices of µTest++
Checks without macros
The checks of µTest++ are function calls that capture the source location with a defaulted parameter, in place of the macros of snitch, GoogleTest, Catch2, doctest, Boost.Test, Unity, and CppUTest. Boost UT also offers a macro-free usage. The consequence is that the checks obey the rules of the language (scope, types, overloads), and that an application comparator is an ordinary template, as described in Expression templates and comparators.
Operands reported by the comparators
Like Boost UT, µTest++ reports the actual operands and the operator of a failed
check. The difference is that it does so through function comparators such as
eq() and lt(), with the operators kept only as a deprecated feature, and
without the C++ stream library; this is the origin of its smaller footprint,
measured in Footprint. The
formatting is described in The expression
formatter.
Reports in TAP
The reports are in the TAP format, which the TAP-aware tools consume directly, with a human-readable reporter on request. The reporter is selected with an option; custom reporters are not supported, whereas Boost UT can replace its reporter and runner, snitch and doctest can register reporters, and Boost.Test, Catch2, GoogleTest, and CppUTest provide several output formats.
Registration with static objects
The suites are defined as static global objects, registered by the static constructors, with the intrusive list of Test cases and suites that does not depend on the construction order. The test cases are not registered: they run within the call that creates them. This differs from the macro-based registration of snitch, GoogleTest, Catch2, doctest, Boost.Test, and CppUTest, and from the runner generation used with Unity.
Embedded targets
The framework is built to run on bare-metal targets, with no dependency on the stream library, with a stack-based execution of the test cases, and with a build that does not use exceptions, where a failed requirement aborts the test execution. snitch, Unity, and CppUTest also target embedded systems; snitch is the closest, a C++20 framework with no stream library and no heap allocation; Unity is written in C and CppUTest is a C++ framework, all three with macros for the checks.
Learning curve
The estimate below is an editorial judgement, not a measurement: no user study was made. It is based on how much a new user must learn before writing a first useful test, how many distinct concepts the framework has, and which mistakes the design makes easy. The sizes are approximate counts from the sources and the documentation folders at the commits in Sources.
| Framework | First test | Full use | API size (approximate) | Main source of difficulty |
|---|---|---|---|---|
| µTest++ | easy for C++ developers | moderate | 12 function comparators and helpers, plus the runner, the suites, and the test cases | the object model (runner, suite, test case, t) and the mt:: qualification |
| Boost UT | moderate | steep | 48 exported names and 3370 lines in a single header | operators, literals, and the | syntax |
| snitch | easy | moderate | 36 documented macros; a README and 3 documentation pages, about 11 000 words, and about 4100 lines of headers | the fixed capacities, the build configuration macros, and the missing Catch2 features |
| GoogleTest | easy | moderate to steep | about 42 EXPECT_* and ASSERT_* macros; 19 documentation pages, about 66 000 words | fixtures, parametrised tests, GoogleMock |
| Catch2 | easy | moderate | few assertion macros; 35 documentation pages, about 51 000 words | sections and generators re-run the test case |
| doctest | easy | moderate | about 66 assertion macros; 16 documentation pages, about 18 000 words | subcases, configuration macros |
| Boost.Test | moderate | steep | about 93 assertion and suite macros | several usage variants, the Boost build, the test tree |
| Unity | easy | moderate | about 450 typed TEST_ASSERT_* macros | choosing the right typed macro, the runner generator |
| CppUTest | moderate | moderate | about 60 assertion macros | the build flags, the memory-leak detector |
The first-test column is the effort to get a failing check reported; the full-use column is the effort to use fixtures, parametrised tests, custom types, and the command line with confidence.
µTest++
The comparators are few and regular (eq(), ne(), lt(), le(), gt(),
ge(), and the others), and there are no macros, so the compiler diagnostics
refer to ordinary functions. The difficulties are of another kind:
- The object model must be learned first. A test is written on an object
(
t.expect (...)), obtained from a suite, itself obtained from a runner. A test is not a free function or a macro as in the other frameworks. - The function comparators are an unusual idiom. A user who writes
t.expect (answer () == 42)gets a check that passes or fails without the operands;t.expect (mt::eq (answer (), 42))is needed for the report. The deprecated operators are a source of confusion in older examples. - The namespace must be written. The guide recommends the
mt::prefix, so the checks are longer thanCHECK_EQ. - The requirement of C++20 can be a difficulty for a project that does not
yet use it; the header stops older compilers with an explicit
#error. - No fixtures, mocks, or leak detection. A user coming from GoogleTest or CppUTest must find other ways; the framework has no page that maps their concepts.
- The embedded set-up is outside the framework. Semihosting, the console, and the start-up code are explained in the User's Guide, but they remain a larger task than the first check.
Boost UT
The macro-free syntax is compact but unusual: the literals ("name"_test,
42_i), the assignment of lambdas, the | operator for parametrised tests,
the >> fatal suffix, and the cfg<override> configuration. Errors in
template-heavy expressions produce long compiler messages. The single header
has 3370 lines and relies on concepts and, when available, <format>.
snitch
The first test is as simple as in Catch2, since the macros and the comparison operators are the same, and the documentation is short. The difficulties are of the embedded kind:
- The API is a subset of Catch2. A user who knows Catch2 must check the
comparison page:
no
GENERATE, no streaming inINFO, noBENCHMARK, and only some of the exception checks. - The capacities are fixed. The number of test cases, the length of the names, of the expressions, and of the messages are set at build time; a larger application needs the configuration, and long text is truncated.
- The behaviour changes without exceptions. A failed
REQUIREstops the application, not only the test case, so theCHECKvariants and a manual return must be used. - The configuration is by build options. The console, the file output, the exceptions, the timings, and the reporters are switched by CMake or meson options, or by macros, and the freestanding functions must be set before any other call.
- Sections re-run the test case, as in Catch2.
GoogleTest
The first test is easy, and the documentation is complete, but long. The
difficulties come later: the difference between EXPECT_* and ASSERT_*
(which only returns from the current function), the fixtures with TEST_F,
the parametrised tests with TEST_P and INSTANTIATE_TEST_SUITE_P, the
death tests, and the matcher language of GoogleMock. The build is the other
cost: the library must be built with the same flags as the tests.
Catch2
The first test is the simplest of all: one macro, and natural comparison
operators. The model needs care later: the SECTION blocks re-run the test
case from the start for each leaf, which surprises the users who expect a
single run; GENERATE has the same effect. The split of v3 into a compiled
library, and the many reporters, listeners, and matchers, add to the
documentation that must be read.
doctest
The API follows Catch2 closely, so the first test is equally easy, and the
documentation is the shortest of the C++ frameworks. The configuration is by
macros defined before the include (DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN, and
others), which must be set in exactly one source file. The
SUBCASE semantics are those of the Catch2 sections.
Boost.Test
The several usage variants (header-only, static, shared) and the choice of the
entry point are the first obstacle. The test tree with decorators,
dependencies, labels, and fixtures is powerful and takes time to master. The
tools are numerous (BOOST_CHECK, BOOST_REQUIRE, BOOST_TEST, and the
_EQUAL and _MESSAGE variants). The dependence on the rest of Boost makes
the set-up heavier outside a Boost project.
Unity
Writing a test is simple: a function and RUN_TEST(). The difficulties are the
size of the macro set, since each type has its own assertion (_INT, _UINT8,
_FLOAT, _STRING, _MEMORY, and so on) and a wrong choice gives a wrong or
unreadable report; the need to run the Ruby script, or to maintain the list
of tests by hand; and the absence of C++ features, such as the destructors on
failure (longjmp()). The documentation is split between the core, the
extras, Ceedling, and CMock.
CppUTest
The macros are few and the test groups are easy to read. The difficulties are
the build configuration (the C and C++ library switches, the exceptions, and
the RTTI), and the memory-leak detector, which redefines new and conflicts
with the code that declares its own operator new, so the include order
matters. The leak failures that come from the lazy initialisation of the
tested code are confusing at first.
Limits and trade-offs of µTest++
- No compile-time variants of the checks.
expect()andrequire()run at run time; the function comparators can be used instatic_assert()(see the User's Guide), but a failure there is reported by the compiler, without the operands. snitch hasCONSTEXPR_*andCONSTEVAL_*variants of its check macros. - No mocking. GoogleTest includes GoogleMock and CppUTest includes CppUMock. With Unity, the mocks come from the separate CMock project.
- No leak detection. CppUTest takes a checkpoint of the allocations before
the set-up and compares it after the tear-down; Unity has an optional
add-on that tracks the
malloc()andfree()calls. - No fixture classes. The body of a suite or of a test case is ordinary code, shared by the nested test cases; the fixtures of GoogleTest, Boost.Test, and doctest have no direct equivalent.
- No custom reporters. See above; snitch registers them with
REGISTER_REPORTER. - A requirement of C++20. Boost UT and snitch have the same requirement, but doctest needs C++11, Catch2 v3 needs C++14, and GoogleTest 1.18.x needs C++17. An embedded toolchain without C++20 cannot build µTest++.
- A small ecosystem. The user community and the third-party tooling are much smaller than those of GoogleTest and Catch2.
Sources
The footprint was measured at the release tags below, with µTest++ at commit
59947cf1 (2026-11-15); the versions are also listed in
frameworks.jsonc,
from which the test scripts fetch them.
| Framework | Release | Commit |
|---|---|---|
| Boost UT | v2.3.1 | f923e6fe |
| snitch | v1.3.2 | cec4a04b |
| GoogleTest | v1.18.0 | 063de7e9 |
| Catch2 | v3.16.1 | 08092139 |
| doctest | v2.5.3 | 2d0a9359 |
| Boost.Test | Boost 1.92.0 | the release archive |
| Unity | v2.7.0 | b6763fbd |
| CppUTest | v4.0 | 67d2dfd4 |
The other statements about the frameworks come from their documentation and from their source code, consulted in November 2026 on the development branches, close to these releases; a feature that is only on a development branch (snitch, for example, was at version 1.4.0) may be described here before it is released.
The frameworks change; verify the details before relying on them, and update this page when a statement is found to be out of date.