Is there an option to print stacktrace when test fails in GTEST on GCC? Is there an option to print stacktrace when test fails in GTEST on GCC? linux linux

Is there an option to print stacktrace when test fails in GTEST on GCC?


There is not "fully" documented option: --gtest_stack_trace_depth=10 (10 is just example value).

It must be used with --gmock_verbose=info

And yes - it works for failing EXPECT_CALL - in gmock only.

For asserts (like ASSERT_EQ) it has less sence - since ASSERT is just where it is - its tack trace is empty (meaning does not contain any of non-gtest/UT code).

An example:

some_test --gmock_verbose=info --gtest_stack_trace_depth=10


If you believe it shall work also for ASSERT* - you might raise an issue here: https://github.com/google/googletest/issues