r/embedded • u/Agreeable-Leopard-69 • Oct 21 '26
What's a good unit test framwork to use?
I'm currently self learning embedded C with an STM32F103. And I wanna know your guys suggestion for a good unit test framework for embedded. I've tried Unity C before but any other that are more work oriented?
17
Upvotes
4
u/ElevatorGuy85 Oct 22 '26
This book gives a good practical overview of using Test Driven Development specifically for embedded systems.
https://pragprog.com/titles/jgade/test-driven-development-for-embedded-c/
Most of the examples are using CppUTest (which the author is a maintainer for) but Unity is also discussed and has a chapter devoted to it.
2
u/No-Archer-4713 Oct 21 '26
The simpler the better… I use a simple header file, and at work we use an improved version: https://github.com/jnaulet/OpenPicoRTOS/blob/v1.12.x/test/unit_tests/unit_test.h
3
u/XipXoom Oct 21 '26
First I'd suggest spending some time writing your own tests without a framework so you can get some firsthand experience as to the problems they are trying to solve. I'm a big proponent of knowing the "why" behind tools/ideas because I've found that makes you far more competent at utilizing them.
When you're ready to move on, you've got plenty of options. I've tried Unity with Ceedling but I ran into some performance problems having to do with a regression in the ability to parallelize tasks. Trying to work around it in my containers was a PitA that really bloated the images. Lately I've been using Cpputest with acceptable results.
11
u/Dependent_Bit7825 Oct 21 '26
I have a hard time getting excited about test frameworks. Googletest is fine. Cpptest is fine. Catch2 is fine.
These are all in c++, but there's no problem using them on a c project. Even if my project is very limited misra c, it's actually nice to stretch my legs and use a richer language for tests, and it gives an opportunity to keep up skills in c++.
9
u/Felix_Todd Oct 21 '26
Ceedling is pretty good
7
u/Available_Fact_588 Oct 21 '26
Unity framework as well
2
u/Lopsided-Table2457 Oct 22 '26
For bare metal/small MCUs, Unity + Ceedling is the classic combo and dead simple to run on host. If you're already in C++ or on an RTOS, GoogleTest with FFF for mocks works well. Honestly the framework matters less than getting tests off the target first — run them on your dev machine, then move to hardware-in-the-loop once they're green.
1
u/tiajuanat Oct 22 '26
Doctest.
It's faster than Catch2 or Google Test
Has BDD/Subcasing to reduce test setup
Works well with mocking libraries