为什么谷歌测试不打印堆栈跟踪或文件名

Why does Google Test not print a stack trace or file name?

本文关键字:跟踪 文件名 堆栈 打印 谷歌 测试 为什么      更新时间:2023-10-16

当我使用Google Test和Google Mock时,诊断级别设置为"info",我收到如下消息:

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 不包括堆栈开卷机。你必须提供你自己的。 您可以在 include/gtest/internal/custom/gtest.h 中通过定义 指向实现的GTEST_OS_STACK_TRACE_GETTER_宏 OsStackTraceGetterInterface.

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