2011-04-01 66 views
6

模拟类看起来像这样: struct MockClass MOCK_METHOD0(foo,void()); };C++ googlemocks:获取未初始化的调用的堆栈跟踪

如果我忘了一个模拟对象上设置的预期电话,我得到的是这样的:

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

和堆栈跟踪是空的。

那么,为了获得堆栈跟踪,需要做些什么?

回答

9

这说明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" ;

使用信息警戒线将打印回溯

+4

不为我工作,堆栈跟踪仍然是空的。 – jupp0r 2014-06-02 09:59:51

+0

我的也是空的 – Bigbohne 2015-09-16 13:39:20