PHPUnit 和 XDebug 可以一起工作吗?
我一直致力于为我的 PHP 代码编写单元测试。 我为此使用的是 PHPUnit。
我有一些类可以很好地工作,直到...
我将 XDebug 加入其中。
那时,PHPUnit 不会崩溃或发生任何事情,但 setExpectedException 永远不会触发。
事实上,代码永远不会超出这一点。
有人遇到过这个问题并知道解决方案是什么吗?
编辑:这是 PHP5.2.6、XUnit 和 XDebug 的最新版本。 这是在 Linux Fedora 7 上
I've been working on writing unit tests for my PHP code. PHPUnit is what I'm using for this.
I have some classes that work great until...
I throw XDebug into the mix.
At that point, PHPUnit doesn't crash or anything, but setExpectedException never triggers.
In fact, the code never goes beyond that point.
Anyone run across this and know what the solution is?
Edit: This is with the PHP5.2.6, Latest versions of XUnit and XDebug. This is on linux fedora 7
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我之前在使用 Xdebug 和 Xdebug 的组合时遇到过一些问题。 PHPUnit(和其他人一样,来自我当时在 devzone.zend.com 上所说的报告),但是是不久前的事了。 PHPUnit 确实明确支持 Xdebug,而且我正在使用它为我自己的系统生成代码覆盖率报告。
我建议使用相当标准的调试技术,更新您可以的任何版本(甚至可能是 PHP?)注释掉 @setExpectedException,或显式抛出它 - 当然,确保您有完整的警告和错误显示
error_reporting(E_ALL|E_STRICT);
设置为开。不要忘记停止并重新启动 Apache 服务器以确保 Xdebug 模块也已加载。
I've had some problems before with one combination of Xdebug & PHPUnit (as did others, from a report I say on devzone.zend.com at the time), but that was a while ago. PHPUnit does explicitly support Xdebug though - and I'm using it to produce code coverage reports for my own systems.
I'd suggest the fairly standard debugging techniques, updating any versions you can (maybe even PHP?) commenting out the @setExpectedException, or throwing it explicitly - and of course, making sure that you have full warnings and errors being shown with
error_reporting(E_ALL|E_STRICT);
set on.Don't forget to stop and restart the Apache server to make sure that the Xdebug module is loaded as well.