I'm trying to mock some functions using cmocka:
void test_led_driver_NeedToImplement(void **state)
{
state_t current = CLEAR;
will_return(led_status_toggel,SET);
TEST_ASSERT_EQUAL(SET, led_status_toggel(current));
}
But, I get an error: led_status_toggel() has remaining non-returned values. Do I have to create a mock file for my functions or what's the source of this error? Ps: I'm using unity.h as an assertions library.
According to your test, it seams that function you are testing is
led_status_toggel. If that is the case, you should not mock it. You should just removewill_return(led_status_toggel,SET);, since yourled_status_toggelis probably something like this (You dind't share it so I don't know exactly):If your function under test is not
led_status_toggel, but some other (that you didn't mentioned) which calls thisled_status_toggel, then you can mock this function like thisand use
-Wl,--wrap=led_status_toggelin your build command. With--wraplinker flag, when you execute your test, the mock function__wrap_led_status_toggelwill be called instead of the originalled_status_toggel.