Mocking IDF components with Unity & CMock

spicy_guava
Posts: 1
Joined: Thu Mar 25, 2021 8:32 pm

Mocking IDF components with Unity & CMock

Postby spicy_guava » Thu Mar 25, 2021 9:09 pm

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!

flonas
Posts: 3
Joined: Mon Aug 16, 2021 6:11 am

Re: Mocking IDF components with Unity & CMock

Postby flonas » Wed Oct 06, 2021 2:21 pm

Hello,

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

Thanks

Who is online

Users browsing this forum: No registered users and 231 guests