php - 为什么 PHPUnit 隐藏我的 xdebug 回溯?

标签 php phpunit xdebug backtrace

我安装了 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 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.

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

关于php - 为什么 PHPUnit 隐藏我的 xdebug 回溯?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6934216/

相关文章:

php - 安排执行一次的 PHP 脚本

docker - 通过PhpStorm运行PHPUnit之前在Docker容器中禁用Xdebug

php - 为 PHPUnit 创建一个基本测试类并将其扩展为通用功能会导致类未找到错误

php - Netbeans Xdebug 安装+PHP+ ubuntu 操作系统

php - Eclipse PDT/XDebug - 如何向后移动指令指针?

php - 如何调试安装到在 docker beta for mac 上运行的容器的 php

php - 如何避免在 php mysql 中插入相同的主键和值

php - 将 zend 项目从 Windows 转移到 Linux 后出现路由错误

php - 使用模数除以零误差

linux - 如何控制 selenium 远程服务器调用的浏览器将在我的哪个桌面上弹出?