php - 尝试使用 xdebug 在 cli 上调试 phpunit 单元测试失败

标签 php debugging phpunit xdebug phpstorm

我正在使用配置为使用 xDebug 的 PHPStorm(我可以通过网络浏览器进行调试)

我在具有 11854 idekey 的 PHPStorm 中运行调试器,我正在尝试调试单元测试,并且我已经正确设置了断点

所以我通过cli执行了这个命令:

phpunit -d xdebug.profiler_enable=on -d xdebug.idekey=11854 --filter testFunction s_function/sFunctionTest.php

然而,它不会相应地在断点处调试...

当我尝试在测试脚本中执行此操作时:

error_log(ini_get('xdebug.profiler_enable'));
error_log(ini_get('xdebug.idekey'));

它会显示 xdebug.profiler_enable 为 0,而 xdebug.idekey 只是我的用户名。

我做错了什么以及如何让 xdebug 通过 cli 在 phpunit 上工作

最佳答案

您只是将参数设置到 phpunit,而不是 PHP。以下应该做你想做的:

php -d xdebug.profiler_enable=on -d xdebug.idekey=11854 `which phpunit` --filter testFunction s_function/sFunctionTest.php

关于php - 尝试使用 xdebug 在 cli 上调试 phpunit 单元测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17113715/

相关文章:

PHPUnit:模拟 Symfony2 FormBuilderInterface - 类型提示问题

PHPUnit selenium 不支持 sendKeys?

php mongoDB aggregate() 返回 MongoDB\Driver\Cursor 对象而不是结果

php - 我可以在 MYSQ ON 语句中使用 IN 运算符吗

android - 在Eclipse中编译Android App时出错?

.net - 我可以中断标有 DebuggerStepThrough 属性的方法吗?

node.js - 如何将参数传递给nodemon(或node-supervisor)中的可执行文件?

php - 如何模拟对象属性?

php - drupal 在链接 url 前加上 'node'

基于 php 的网站显示基于 URL 的页面内容?