Unit testing C++

Hi all,

I’m searching for a nice unit testing framework for the C++ code we write on Particle devices.
Ideally, it will have to write tests on its own, come on, this is 2022.

I see Device OS tests use Catch2, as mentioned here:

In the same post, there is also a mention of UnitTest++:

Other popular contenders seem to be:

Options for on-board unit tests:

Do you have any experience with any of them or any other?
Would you like to comment on that, please?


I’m a user of CppUTest and I’m happy with it. I’ve not evaluated the others, and I settled with it after reading James Grenning’s book, “Test Driven Development for Embedded C”. His blog is a good resource, as is his TDD class, should you be able to make such a commitment.

I find the ability to create fakes/mocks quite useful given the embedded context. I’ve used it with with code destined for Particle, PIC, STM32, and others.

I have also seen instances of CppUTest being run on-target to demonstrate successful initialization and operation of bare-metal peripherals (e.g. if one was setting up a UART to operate via DMA without using a vendor’s HAL, you can loopback the TX/RX pins, and check inputs_str against output_str, bytes_sent etc.).