简体   繁体   English

c ++ googlemocks:获取未初始化调用的堆栈跟踪

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

Mock class looks like this : struct MockClass { MOCK_METHOD0( foo, void () ); 模拟类看起来像这样: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? 那么,要获得堆栈跟踪还需要做些什么?

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: 您可以使用--gmock_verbose = LEVEL命令行标志控制Google Mock告诉您的程度,其中LEVEL是一个包含三个可能值的字符串:
1. info: Google Mock will print all informational messages, warnings, and errors (most verbose). 1.信息:Google Mock将打印所有信息性消息,警告和错误(最详细)。 At this setting, Google Mock will also log any calls to the ON_CALL/EXPECT_CALL macros. 在此设置下,Google Mock还会记录对ON_CALL / EXPECT_CALL宏的任何调用。
2. warning: Google Mock will print both warnings and errors (less verbose). 2.警告:Google Mock会同时打印警告和错误(不太详细)。 This is the default. 这是默认值。
3. error: Google Mock will print errors only (least verbose). 3.错误:Google Mock只会打印错误(最不详细)。

Alternatively, you can adjust the value of that flag from within your tests like so: 或者,您可以在测试中调整该标志的值,如下所示:
::testing::FLAGS_gmock_verbose = "error" ; ::testing::FLAGS_gmock_verbose = "error" ;

Using the info warning level will print the backtrace 使用信息警告级别将打印回溯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM