Reputation: 12138
Is there a way to disable automatic capturing of C++ exceptions when running unittests with Google test? This in order to get better context of the origin of an error.
Upvotes: 7
Views: 1975
Reputation: 2208
As Yksisarvinen mentioned, by invoking the test executable with --gtest_catch_exceptions=0
you should be able to keep googletest from catching exceptions (if that is what you want - the test application will probably crash messily instead).
That said, it depends on what you want to achieve:
In my test suits I make sure to encapsulate functions that throw()
exceptions in a try-catch block so I can quickly determine what went wrong (if/when they fail), and (if necessary) then manually check the issue with a debugger.
Upvotes: 3