Feature Request: Better debug when mock called fewer times than expected
Currently, when a mock has been called fewer times than expected we get an error such as:
test_foo.c:75 test_that_fails:FAIL:Function some_mock. Called fewer times than expected
Where test_foo.75 is the test_that_fails().
Better would be for it to print out the line of the expect that hasnt been satisfied. This should be possible, as the information is all in the CallInstance in order to validate the call when it is made.
I guess this should probably be an issue ont he Cmock project instead...
Something like this did the job for me. Doesnt print anything useful out, but I can at least access the details and use the debugger
" if (CMOCK_GUTS_NONE != call_instance)\n" \
" {\n" \
" # // NEW LINE HERE!!!!!! "\
**" CMOCK_#{function[:name]}_CALL_INSTANCE* cmock_call_instance=(CMOCK_#{function[:name]}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.#{function[:name]}_CallInstance);\n"\**
" UNITY_SET_DETAIL(CMockString_#{function[:name]});\n" \
" UNITY_TEST_FAIL(cmock_line, CMockStringCalledLess);\n" \
" }\n"
end
Hi @msimpson80 . You're misunderstanding the situation, I believe. When an expectation has not been satisfied, that IS what CMock prints the line for. Your situation is the opposite. The test writer did not expect this function to get called (or expected it to be called fewer times). So most often, there isn't an expectation for this function in the test at all... or in some cases, there IS an expectation, but that one has already been satisfied and we need ANOTHER to be added. Does that make sense?