Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ googlemocks : Getting a stack trace of an uninitialized call

Mock class looks like this : struct MockClass { MOCK_METHOD0( foo, void () ); };

If I forget to set an expected calls on a mock object, I get something like this :

GMOCK WARNING:
Uninteresting mock function call - returning directly.
    Function call: foo()
Stack trace:

and the stack trace is empty.

So, what has to be done in order to get the stack trace?

like image 966
BЈовић Avatar asked Apr 01 '11 08:04

BЈовић


1 Answers

This is described here :

You can control how much Google Mock tells you using the --gmock_verbose=LEVEL command-line flag, where LEVEL is a string with three possible values:
1. info: Google Mock will print all informational messages, warnings, and errors (most verbose). At this setting, Google Mock will also log any calls to the ON_CALL/EXPECT_CALL macros.
2. warning: Google Mock will print both warnings and errors (less verbose). This is the default.
3. error: Google Mock will print errors only (least verbose).

Alternatively, you can adjust the value of that flag from within your tests like so:
::testing::FLAGS_gmock_verbose = "error";

Using the info warning level will print the backtrace

like image 51
BЈовић Avatar answered Sep 28 '22 00:09

BЈовић