Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use googletest Failures into Break-Points

I recently discovered the Failures into Break-Points - option from googletest using the command line option gtest_break_on_failure or by defining the GTEST_BREAK_ON_FAILURE environment variable.

I gave it a try using gtest_break_on_failure. From command line, I saw no effect (to be honest I had the glimpse of hope that VS2010 would be registered as debugger and somehow magically would pop up and point to the error source).

Using it in the VS environment as command line argument a failed assertion triggered a break but the call stack did not include the test method that caused the failure. I found the work around to step (F10) until I reached my test code, but that does not really seem to be convenient.

Is it somehow possible to use the option from command line ?

Has anybody a recommendation how to get the correct call stack in the environment?

like image 789
anhoppe Avatar asked Apr 03 '13 07:04

anhoppe


1 Answers

From VS, you can add --gtest_break_on_failure to the Command Args in the target's Property Pages, then just run the exe without stepping over.

Property Pages showing Command Arguments

From the command line, you should be able to run the Debug executable with the flags --gtest_break_on_failure --gtest_catch_exceptions=0 and this should allow you to break into the MSVC debugger when the test fails.

like image 181
Fraser Avatar answered Oct 05 '22 01:10

Fraser