Using --wrap to mock methods using CMocka


Has anyone mocked methods for UnitTesting using CMocka using platformIO?
I got CMocka working on my native platformIO project. I am not able to get --wrap working to mock a method in my native environment? I was trying to find example usage in general and some says that the test that uses wrap_method and code containing the method to be wrapped needs to compile separately. Is it true?

I was trying to add -Wl,–wrap=EEPROM_IsFactoryMode to build_flags in native environment and it complains about unknown -ld option.

any example or sample use of --wrap with platformIO would be a big help?

Thanks in advance.


1 Like