CPPUTEST: How to ignore only one mocked call placed between other ones

孤街浪徒 提交于 2019-12-12 04:14:01

问题


I would like to ignore one call placed between other ones that I want to call under the same case test. If I use ignoreothercalls I have not clear if the rest of the calls, following this, will be called. I need the rest, after ignored call, will be called. Or at least, to find the way of stopping ignoreothercalls effect before the end of the test case.

TEST(group, test1){

    ...
    mock().expectOneCall("HAL_AS393x_CommandStrobes").withParameter("cCommandCode",AS393X_CMD_CALIB_RCO_LC);    
    /*-------------------------------------------------------*/
    mock().expectOneCall("HAL_AS393x_ReadRegisters");//I want ignore only this mocked function call
    /*-------------------------------------------------*/
    mock().expectOneCall("HAL_AS393x_Deinit");
    ...

}

I would like to leave this call without being tested, and remove it from de test case without gettig expecting calls errors for it: mock().xxxCall("HAL_AS393x_ReadRegisters"); //-where xxxCall = unkown keyword used for this-


回答1:


You have to check expectation in between:

mock().expect...
do_something_that_call_mocks();
mock().checkExpectations();

/* Start all over again */

Complete example using checkExpectations() to reset mock() here



来源:https://stackoverflow.com/questions/41301539/cpputest-how-to-ignore-only-one-mocked-call-placed-between-other-ones

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!