如何从命令行使用 PHPUnit 运行 XDebug?

cod*_*ama 3 windows phpunit netbeans

我有在调试模式下运行的 netbeans。现在我想用 ?XDEBUG_SESSION_START=netbeans-xdebug 运行单元测试,目的是在我运行时设置断点。是否可以?

我试过这样的事情:

phpunit myTest.php?XDEBUG_SESSION_START=netbeans-xdebug
Run Code Online (Sandbox Code Playgroud)

不起作用。有任何想法吗?

更新

根据这个:http : //blog.doh.ms/2011/05/13/debugging-phpunit-tests-in-netbeans-with-xdebug/

转到命令行并运行 phpunit-debug。现在调试开始,如果您选择“在第一行停止”,则 IDE 将打开 phpunit 文件,单击播放即可关闭。

如果我运行 phpunit --debug

Starting test 'xxxx'
OK (1 test, 4 assertions)
Run Code Online (Sandbox Code Playgroud)

问题是,它从来没有捕捉到我在控制器中的断点。为什么抓不住?是否有可能是因为它是使用以下方式执行的:

$this->dispatch('/ajax/update-bla');
Run Code Online (Sandbox Code Playgroud)

小智 5

试试这个
$ XDEBUG_CONFIG="idekey=netbeans-xdebug" phpunit -c %yourconfing%.xml

或者你可以导出 shell var
$ export XDEBUG_CONFIG="idekey=netbeans-xdebug"

然后像往常一样运行 phpunit
$ phpunit -c %yourconfing %.xml