c++ - 为什么 Google Test 不打印堆栈跟踪或文件名?

标签 c++ googletest googlemock

当我使用 Google Test 和 Google Mock 并将诊断级别设置为“信息”时,我收到如下消息:

Uninteresting mock function call - taking default action specified at:
src/pkgtest/test_Foo.cpp:216:
    Function call: GetBar()
          Returns: 4-byte object <00-00 00-00>
Stack trace:

Uninteresting mock function call - taking default action specified at:
src/pkgtest/test_Foo.cpp:126:
    Function call: GetBaz()
          Returns: {}
Stack trace:
unknown file: Failure
C++ exception with description "Uninteresting mock function call - returning default value.
    Function call: CreateGrille(@0x7fff6a557050 { 16-byte object <80-D8 BB-01 00-00 00-00 70-D8 BB-01 00-00 00-00> })
    The mock function has no default action set, and its return type has no default value set." thrown in the test body.

我在互联网上找不到任何关于为什么 Google Test/Mock 不打印堆栈跟踪或声称“未知文件”的信息。我需要做什么来教它如何正确转储堆栈跟踪?

(我在使用 g++ 4.9 的 Linux 上,如果有区别的话。)

最佳答案

根据 Samuel Benzaquen 的说法:

gTest doesn't include a stack unwinder. You have to provide your own. You can do this in include/gtest/internal/custom/gtest.h by defining the GTEST_OS_STACK_TRACE_GETTER_ macro to point an implementation of OsStackTraceGetterInterface.

https://groups.google.com/d/msg/googletestframework/WMJuxAE7y-A/3FjexkRpEQAJ

关于c++ - 为什么 Google Test 不打印堆栈跟踪或文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37814200/

相关文章:

c++ - 在覆盖新运算符时传递更多参数(C++)

c++ - 我应该在游戏中使用引用还是按值传递常用数组 [C++]

c++ - 如何使用 Google Test 检查零个或一个函数调用?

c++ - 从 Google 模拟中的模拟对象返回模拟对象

c++ - 仅在 ASSERT_STREQ 失败时显示差异

java - 单元测试需要很多接口(interface)?

c++ - 读取二进制文件时输出不一致

c++ - 如何从 libcurl 中的 http header 中删除 Accept

cmake - 将 Googletest 添加到现有的 CMake 项目

c++ - 使用 void 函数检查 gtest 中的错误