为什么PHPUnit隐藏我的xdebug回溯? [英] Why does PHPUnit hide my xdebug backtrace?

查看:72
本文介绍了为什么PHPUnit隐藏我的xdebug回溯?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了PHPUnit和xdebug,并且在CLI的php.ini文件中,我已经:

I have PHPUnit and xdebug installed, and in my php.ini files for CLI I've got:

display_errors = On
xdebug.default_enable = 1

我已经验证了使用交互式控制台创建错误时是否打印了xdebug回溯,但是当运行phpunit时发生错误时,是否没有回溯?

I've verified that an xdebug backtrace is printed when I create an error using the interactive console, but when an error occurs while running phpunit, there is no backtrace?

回溯发生了什么事? phpunit对我隐藏了吗?我缺少某些设置吗?

What is happening to the backtrace? Is phpunit hiding it from me? Is there some setting I'm missing?

谢谢!

推荐答案

回溯发生了什么事? phpunit对我隐藏了吗?

What is happening to the backtrace? Is phpunit hiding it from me?

是的,PHPUnit禁用了xdebug,至少禁用了这些跟踪(通过调用 xdebug_disable() 文档 ).

Yes, PHPUnit disables xdebug, at least these traces (by calling xdebug_disable()Docs).

我缺少某些设置吗?

Is there some setting I'm missing?

您可以添加 bootstrap 文件,并在其中再次启用该文件使用 xdebug_enable() Docs .确实可以,但是还会向您显示任何抛出的异常(已捕获或未捕获)的堆栈跟踪.

You can add a bootstrap file in which you enable it again with xdebug_enable()Docs. This does work but will show you stack traces on any exception thrown as well (caught or uncaught).

另请参见:问题#221 PHPUnit禁用xdebug ,还有另一个ini设置建议:

See as well: Issue #221 PHPUnit disables xdebug, there is another ini setting suggested:

sebastianbergmann :问题是xdebug.show_exception_trace配置设置.当设置为1时,它将在引发异常时显示堆栈跟踪-即使实际上已捕获此异常".此行为破坏了PHPUnit的输出.

sebastianbergmann: The problem is the xdebug.show_exception_trace configuration setting. When set to 1, this will "show a stack trace whenever an exception is raised - even if this exception is actually caught.". This behaviour breaks the output of PHPUnit.

现在,如果我没记错的话,Derick建议使用xdebug_disable();而不是ini_set('xdebug.show_exception_trace', 0);.

Now if I remember correctly, Derick recommended using xdebug_disable(); over ini_set('xdebug.show_exception_trace', 0);.

这篇关于为什么PHPUnit隐藏我的xdebug回溯?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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