[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: AW: use will_return_* in fixtures


Hey,

you're right about the missing return 0. However, this has no effect on
the original problem.

> Also, I guess that the mockedFunction should be called from setup
That?s exactly what I don?t want to do. The setup-function should just
setup the test.

It seems the will_return_* functions always have a function scope:
will_return() and the corresponding mock() must always be called within
one function.

I think they should have a test scope (which consists of setup, function
and teardown): will_return() should be callable in setup and the
corresponding mock in function or even teardown.

Does this sound reasonable?

Kind Regards,
Simon


-----Ursprüngliche Nachricht-----
Von: Pawel Szewczyk [mailto:p.szewczyk@xxxxxxxxxxx]
Gesendet: Freitag, 16. Dezember 2016 17:16
An: cmocka@xxxxxxxxxxxxxx
Betreff: Re: AW: use will_return_* in fixtures

Hello,

I think what you are trying to do is possible.

> int setup(void **state){
>
>      will_return(mockedFunction, 10);
>
> }

You will probably want to return 0 from setup if it should be treated as
successful. Also, I guess that the mockedFunction should be called from
setup, otherwise it will fail due to non-returned values even when the
function was called from test function (shouldn't it however be
possible?).

Best Regards,
Pawel Szewczyk



Attachment: cmocka_will_return_in_fixture_problem.c
Description: Binary data


References:
use will_return_* in fixturesSimon Röhrl <simon.roehrl@xxxxxxxxxxxx>
Re: use will_return_* in fixturesJoseph.Ates@xxxxxxxxxxxxx
AW: use will_return_* in fixturesSimon Röhrl <simon.roehrl@xxxxxxxxxxxx>
Re: AW: use will_return_* in fixturesPawel Szewczyk <p.szewczyk@xxxxxxxxxxx>