ThrowTheSwitch / CMock

CMock - Mock/stub generator for C
http://throwtheswitch.org
MIT License
671 stars 273 forks source link

Ignore calling order of mocked functions #439

Open gorogbalazs opened 1 year ago

gorogbalazs commented 1 year ago

(This is a feature request, I hope this is the right place for it.)

It would be nice to have some way to ignore calling order of mocked functions. E.g.

    for (uint8_t i = 0; i < n; i++)
    {
        Cmock_start_ignore_call_order();
        functionA_Expect(...);
        functionB_Expect(...);
        functionC_Expect(...);
        functionD_Expect(...);
        Cmock_stop_ignore_call_order();
    }

In my case it does not matter, whether I call functionA first or functionD, what matters is that all of them are called with the correct values. Currently this can only be implemented with a lot of boilerplate, if I also want to check the parameter values (add stubs, set flags, use global vars, etc.).

mvandervoord commented 1 year ago

Hi. This feature exists. In your project configuration file, set the following:

:cmock:
  :enforce_strict_ordering: false
gorogbalazs commented 1 year ago

Thank you for your fast reply. If I understand you correctly, that setting is going to turn off order checking in all the tests in the project. What if I only want to apply it for a specific subpart of the tests (e.g. only 1 or 2 functions of the unit under test)? Is there a feature to solve that?

mvandervoord commented 1 year ago

At the moment there is not.