How to get a call stack upon failed assertions and runtime errors?

840 views
Skip to first unread message

Alain Désilets

unread,
Nov 27, 2013, 10:24:44 AM11/27/13
to googletes...@googlegroups.com
Hi all. I am a developer with 12 experience doing TDD in different languages (Java, PHP, Python, Perl), but haven't done C++ in 20 years.

I just started using Google Test and am slowly warming up to it (it's pretty different from the xUnit flavors I have used in other languages).

One thing that I find myself craving is a complete callstack of where the error or runtime error occured. This is a pretty much standard feature of all other xUnit frameworks I have used.

For failed assertions, I am able to provide a callstack "simile" by putting SCOPED_TRACE() calls at strategic places in my test code and custom assertions.

But that doesn't work for runtime errors, because I would have to sprinkle SCOPED_TRACE() all over the place in my production code (for example, at the beginning of every method or at least every important method), and that would pollute my production code too much.

I was wondering if people have tricks or best practices for dealing with that situation?

For example, Boost.Test has a command line option to tell the framework to invoke the debugger upon uncaught exceptions which are not assertion exceptions. Is there a similar option for GoogleTest?

And speaking of command line options, where can I find a list of all the available options? I have beeen googling for 10 mins now, and although I find references and explanations of specific options like --gtest_filter, I haven't found a page that explains all the available options.

Thx.

Alain Desilets
Owner, Alpaca Technologies
alpacatechnologies.com

Vlad Losev

unread,
Nov 30, 2013, 12:16:00 AM11/30/13
to Google C++ Testing Framework
Google Test has the --gtest_break_on_failure option which will execute DebugBreak() on Windows or generate a SIGSEGV on *nix systems when it detects a failure. If you are running under debugger, that will drop you into the debugger which will allow you to inspect the stack. You can find more information in the Google Test wiki at https://code.google.com/p/googletest/wiki/AdvancedGuide. Also, invoking the test binary with the --help should give you the list of available flags with brief descriptions. 


--
 
---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Alain Désilets

unread,
Dec 2, 2013, 1:45:07 PM12/2/13
to googletes...@googlegroups.com


On Saturday, 30 November 2013 00:16:00 UTC-5, Vlad Losev wrote:
Google Test has the --gtest_break_on_failure option which will execute DebugBreak() on Windows or generate a SIGSEGV on *nix systems when it detects a failure. If you are running under debugger, that will drop you into the debugger which will allow you to inspect the stack. You can find more information in the Google Test wiki at https://code.google.com/p/googletest/wiki/AdvancedGuide. Also, invoking the test binary with the --help should give you the list of available flags with brief descriptions. 

Thx a million. This is exactly what I am looking for.

Alain
Reply all
Reply to author
Forward
0 new messages