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)?
Asked
Active
Viewed 6,558 times
8
-
See http://stackoverflow.com/a/26583406/6394138 – Leon Jul 18 '16 at 14:21
1 Answers
2
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

PiotrNycz
- 23,099
- 7
- 66
- 112
-
1Does not work for me: for running `./build/tests --gtest_stack_trace_depth=10 --gmock_verbose=info` I'm getting an assert in my code, but no stacktrace. – Hi-Angel Nov 09 '18 at 13:10
-
@Hi-Angel I mentioned in my answer - raise any complaints here: https://github.com/google/googletest/issues I am not maintainer of gmock/gtest so I cannot help more than what is already in my answer – PiotrNycz Nov 09 '18 at 17:48
-
Well, if I understand correctly, you meant it doesn't work with `ASSERT`s defined by GTest, whereas I meant a plain C/C++ `assert()` function. Anyway, to report an issue I have to have a clear source which says that the option supposed to make GTest to print a stacktrace on crash, so I could report "look, it doesn't work as documented". And I didn't find any. How did you find that it's supposed to work? – Hi-Angel Nov 09 '18 at 21:28