Page 1 of 1

Mocking IDF components with Unity & CMock

Posted: Thu Mar 25, 2021 9:09 pm
by spicy_guava
I'm attempting to mock hardware-dependent IDF components so I can implement unit testing. I'm using IDF v4.3, which has cmock as a component.

I've managed to generate cmock mocks for the driver/touch_sensor.h header file, using the CMakeLists.txt in the spi_flash component for reference. When I include functions from my code under test (that contain #include "driver/touch_sensor.h") in my test cases, I find I get multiple definition errors. This is due to both the presence of original component function definitions, and the mocked versions being present in the executable.

Is there a way of compiling this test, but excluding only the original component that is being mocked, in order to avoid these errors?

Thanks!

Re: Mocking IDF components with Unity & CMock

Posted: Wed Oct 06, 2021 2:21 pm
by flonas
Hello,

I have the exact same issue, does anyone have found a solution for excluding the original IDF component?

Thanks