如何使用googletest失败进入断点 [英] How to use googletest Failures into Break-Points

查看:241
本文介绍了如何使用googletest失败进入断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近通过使用命令行选项 gtest_break_on_failure 或通过定义 GTEST_BREAK_ON_FAILURE 环境变量,发现googletest中的失败点为



我尝试使用 gtest_break_on_failure 。从命令行来看,我没有看到任何效果(说实话,我看到VS2010将被注册为调试器,而且以某种方式幻想地弹出并指向错误源)。



在VS环境中使用它作为命令行参数,失败的断言触发中断,但调用堆栈不包括导致失败的测试方法。我找到了工作(F10),直到我达到我的测试代码,但这似乎并不方便。



是否有可能使用命令行中的选项?



有人建议如何在环境中获取正确的调用堆栈?

解决方案

从VS,您可以将 - gtest_break_on_failure 添加到目标的属性页面,然后只运行exe,而不会跳过。





从命令行,您应该可以使用标志运行Debug可执行文件 - gtest_break_on_failure --gtest_catch_exceptions = 0 这样就可以让您在测试失败时进入MSVC调试器。


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?

解决方案

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.

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.

这篇关于如何使用googletest失败进入断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆