【发布时间】:2018-03-07 09:38:07
【问题描述】:
我运行了这个命令:
"C:\xampp\php\.\php.exe" "C:\xampp\php\phpunit" -d xdebug.profiler_enable=on -d xdebug.idekey=VSCODE
C:\xampp\php\php.ini 有以下内容:
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.5.0-7.1-vc14.dll"
xdebug.idekey=VSCODE
xdebug.profiler_enable=1
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
如果我在没有 Listen for XDebug 的情况下运行命令,我将在命令行窗口中看到以下内容:
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 3.7.21 by Sebastian Bergmann.
Configuration read from C:\xampp\apps\summit\htdocs\wp-content\plugins\hl-market-tracker\phpunit.xml.dist
...
我进入 VSCode 并监听 XDebug,当我运行命令时,我看到请求 1 和 2 出现在调用堆栈中,但没有运行单元测试(它似乎挂在某个地方,因为 Installing... 甚至没有显示在命令行窗口中)。如果我停止监听 Xdebug,我会在调试控制台中看到read ECONNRESET,然后我会看到打印出Running as single site... 语句(但不是Installing... 语句)
问题:
我想了解当我尝试运行单元测试时如何让调试工作?
为什么我看到了上述挂起行为?我不明白什么?
参考文献:
【问题讨论】:
-
我想我遇到了这个问题,但我不知道如何解决这个问题,以便我可以为 WP 插件编写单元测试。 github.com/felixfbecker/vscode-php-debug/issues/164
标签: php visual-studio-code xdebug