我安装了 PHPUnit 和 xdebug,在我的 CLI 的 php.ini 文件中我有:
display_errors = On
xdebug.default_enable = 1
我已经确认在使用交互式控制台创建错误时打印了 xdebug 回溯,但是当运行 phpunit 时发生错误时,没有回溯?
回溯发生了什么? phpunit 对我隐瞒了吗?是否缺少某些设置?
谢谢!
最佳答案
What is happening to the backtrace? Is phpunit hiding it from me?
是的,PHPUnit 禁用了 xdebug,至少是这些痕迹(通过调用 xdebug_disable()
Docs)。
Is there some setting I'm missing?
您可以添加 bootstrap使用 xdebug_enable()
Docs 再次启用它的文件.这确实有效,但也会向您显示抛出的任何异常(捕获或未捕获)的堆栈跟踪。
另见:Issue #221 PHPUnit disables xdebug ,还有另一个建议的 ini 设置:
sebastianbergmann: The problem is the
xdebug.show_exception_trace
configuration setting. When set to1
, 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.Now if I remember correctly, Derick recommended using
xdebug_disable();
overini_set('xdebug.show_exception_trace', 0);
.
关于php - 为什么 PHPUnit 隐藏我的 xdebug 回溯?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6934216/