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

AW: use will_return_* in fixtures

Thank you for your quick reply and the hint, but I don?t think this is the
problem. Following is a minimal example demonstrating the issue:

#include <setjmp.h>

#include <cmocka.h>

int mockedFunction(int a, int b){

    return mock();


void testFoo(void **state){

   /* this is don?t care */

    assert_int_equal(1, 1);


int setup(void **state){

    will_return(mockedFunction, 10);


int main(void){

    int retval = 0;

    const struct CMUnitTest fixture_problem_test[] = {

        cmocka_unit_test_setup(testFoo, setup),


    retval = cmocka_run_group_tests(fixture_problem_test, NULL, NULL);

    return retval;


The output is:

[==========] Running 1 test(s).

[ RUN      ] testFoo

Could not run the test - check test fixtures

[  ERROR   ] testFoo

[==========] 1 test(s) run.

[  PASSED  ] 0 test(s).

I can?t see what is wrong with this. Any help is appreciated.



Von: Joseph.Ates@xxxxxxxxxxxxx [mailto:Joseph.Ates@xxxxxxxxxxxxx]
Gesendet: Freitag, 16. Dezember 2016 14:53
An: Simon Röhrl
Cc: cmocka@xxxxxxxxxxxxxx
Betreff: Re: use will_return_* in fixtures

This usually indicates that there is a failed assertion within a test's
setup fixtures. It can be mitigated by not calling asserts in your test
setup by checking those assertions in a separate test prior to using the
test fixtures.

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