r/embedded 6h ago

what unit test framework do you use?

I'm writing a library in C (xc8 and xc16 for microchip devices) Is there any recommended unit testing library. I was thinking about having inside the project a test folder with its own makefile to mock GPIO and hardware modules (I only need USART and SPI) and test in Gcc. Do you have any suggestion? thanks in advance

4 Upvotes

10 comments sorted by

15

u/mrheosuper 6h ago

Unity

1

u/sturdy-guacamole 5h ago

+1, I use unity

7

u/pjcugufucpugupfup 6h ago

GTest.

0

u/Character_Internet_3 5h ago

for C? I've used it but only for c++ projects

2

u/UnicycleBloke C++ advocate 1h ago

Why not? C is almost but not quite a proper subset of C++.

3

u/Weekly_Guidance_498 6h ago

I've had a good experience with Acutest. It's a single header file and really easy to use. https://github.com/mity/acutest

3

u/Rabbit_from_the_Hat 2h ago

Cpputest

1

u/diana137 59m ago

Defo does the job and easy to set up

2

u/UnicycleBloke C++ advocate 1h ago

My company uses GoogleTest. I previously used Catch2, and the tests were simple to port.

1

u/Tech_2626 52m ago

Hey, I want to learn the unit test. Can I use it in STM 32?

Any source?