2011-04-01 67 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