简体   繁体   English

如何使用 googletest 失败进入断点

[英]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.我最近使用命令行选项gtest_break_on_failure或通过定义GTEST_BREAK_ON_FAILURE环境变量从 googletest 中发现了故障进入断点 - 选项

I gave it a try using gtest_break_on_failure .我尝试使用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).从命令行,我没有看到任何效果(老实说,我有一丝希望 VS2010 将被注册为调试器,并以某种方式神奇地弹出并指向错误源)。

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.在 VS 环境中将其用作命令行参数,失败的断言触发了中断,但调用堆栈不包括导致失败的测试方法。 I found the work around to step (F10) until I reached my test code, but that does not really seem to be convenient.在到达我的测试代码之前,我找到了步骤 (F10) 的工作,但这似乎并不方便。

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.在 VS 中,您可以将--gtest_break_on_failure添加到目标属性页中的 Command Args 中,然后直接运行 exe 而无需跨步。

显示命令参数的属性页

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.从命令行,您应该能够使用标志--gtest_break_on_failure --gtest_catch_exceptions=0运行调试可执行文件,这应该允许您在测试失败时闯入 MSVC 调试器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM