Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I use GTEST with GCC on Linux. I want to see stacktrace printed on test fail (be it assert or signal based crash). It can be done manually, yet I wonder if it can be set as GTEST build/run option (without more than one line modifications to my codebase)?

like image 568
DuckQueen Avatar asked Jul 18 '16 13:07

DuckQueen


1 Answers

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

like image 73
PiotrNycz Avatar answered Oct 04 '22 16:10

PiotrNycz