带有xdebug的PHpUnit在BaseTestRunner而不是实际测试处中断 [英] PHpUnit with xdebug Breaks at BaseTestRunner instead of the actual test

查看:49
本文介绍了带有xdebug的PHpUnit在BaseTestRunner而不是实际测试处中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下配置设置了Xdebug远程调试:

I have setup Xdebug remote debugging with the following configuration:

我在phpunit测试中放置了一个断点:

I placed a breakpoint in my phpunit test:

<?php declare (strict_types = 1);

namespace Tests\Api;

class MyControllerTest extends ApiTestCase
{
    public function myTest()
    {
        // Breakpoint goes here
        //Rest Of code
    }
}

然后,我将Xdebug设置为侦听xdebug.在远程服务器(虚拟机)上,我运行以下命令:

Then I set the Xdebug to listen for the xdebug. ON the remote server (vagrant VM) I run the following commands:

export XDEBUG_CONFIG="idekey=VSCODE"
phpunit ./tests/app/MyControllerTest.php

但是我的VSCode(UFING vscodium叉)在 vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php 上中断,而不是在xdebug日志中看到的由于反射导致的实际单元测试:

But my VSCode (ufing vscodium fork) breaks upon vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php Instead of the actual unit test due to refrlection as seen in the xdebug log:

[98] Log opened at 2019-10-18 08:07:04
[98] I: Connecting to configured address/port: 10.0.2.2:9000.
[98] I: Connected to client. :-)
[98] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/vendor/phpunit/phpunit/phpunit" language="PHP" xdebug:language_version="7.2.20" protocol_version="1.0" appid="98" idekey="VSCODE"><engine version="2.7.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2019 by Derick Rethans]]></copyright></init>
[98]
[98] <- breakpoint_list -i 1
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>
[98]
[98] <- breakpoint_list -i 2
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="2"></response>
[98]
[98] <- breakpoint_list -i 3
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="3"></response>
[98]
[98] <- breakpoint_list -i 4
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="4"></response>
[98]
[98] <- breakpoint_list -i 5
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="5"></response>
[98]
[98] <- breakpoint_list -i 6
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="6"></response>
[98]
[98] <- breakpoint_set -i 7 -t line -f file:///var/www/html/app/Http/Middleware/AuthorizeGiaolaClient.php -n 26
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="980001"></response>
[98]
[98] <- breakpoint_set -i 8 -t line -f file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php -n 116
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" id="980002"></response>
[98]
[98] <- breakpoint_set -i 9 -t line -f file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php -n 125
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="980003"></response>
[98]
[98] <- breakpoint_set -i 10 -t line -f file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php -n 127
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="10" id="980004"></response>
[98]
[98] <- breakpoint_set -i 11 -t line -f file:///var/www/html/public/index.php -n 10
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="11" id="980005"></response>
[98]
[98] <- breakpoint_set -i 12 -t line -f file:///var/www/html/app/Communications/Infobip/MessageInterface.php -n 8
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="12" id="980006"></response>
[98]
[98] <- breakpoint_set -i 13 -t line -f file:///var/www/html/app/Controllers/Mobile/V4/ReservationController.php -n 18
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="13" id="980007"></response>
[98]
[98] <- breakpoint_set -i 14 -t line -f file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php -n 288
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="14" id="980008"></response>
[98]
[98] <- breakpoint_set -i 15 -t line -f file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php -n 369
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="15" id="980009"></response>
[98]
[98] <- breakpoint_list -i 16
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="16"><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="127" state="enabled" hit_count="0" hit_value="0" id="980004"></breakpoint><breakpoint type="line" filename="file:///var/www/html/public/index.php" lineno="10" state="enabled" hit_count="0" hit_value="0" id="980005"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Communications/Infobip/MessageInterface.php" lineno="8" state="enabled" hit_count="0" hit_value="0" id="980006"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Controllers/Mobile/V4/ReservationController.php" lineno="18" state="enabled" hit_count="0" hit_value="0" id="980007"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Http/Middleware/AuthorizeGiaolaClient.php" lineno="26" state="enabled" hit_count="0" hit_value="0" id="980001"></breakpoint><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="116" state="enabled" hit_count="0" hit_value="0" id="980002"></breakpoint><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="125" state="enabled" hit_count="0" hit_value="0" id="980003"></breakpoint><breakpoint type="line" filename="file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php" lineno="288" state="enabled" hit_count="0" hit_value="0" id="980008"></breakpoint><breakpoint type="line" filename="file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php" lineno="369" state="enabled" hit_count="0" hit_value="0" id="980009"></breakpoint></response>
[98]
[98] <- breakpoint_list -i 17
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="17"><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="127" state="enabled" hit_count="0" hit_value="0" id="980004"></breakpoint><breakpoint type="line" filename="file:///var/www/html/public/index.php" lineno="10" state="enabled" hit_count="0" hit_value="0" id="980005"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Communications/Infobip/MessageInterface.php" lineno="8" state="enabled" hit_count="0" hit_value="0" id="980006"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Controllers/Mobile/V4/ReservationController.php" lineno="18" state="enabled" hit_count="0" hit_value="0" id="980007"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Http/Middleware/AuthorizeGiaolaClient.php" lineno="26" state="enabled" hit_count="0" hit_value="0" id="980001"></breakpoint><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="116" state="enabled" hit_count="0" hit_value="0" id="980002"></breakpoint><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="125" state="enabled" hit_count="0" hit_value="0" id="980003"></breakpoint><breakpoint type="line" filename="file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php" lineno="288" state="enabled" hit_count="0" hit_value="0" id="980008"></breakpoint><breakpoint type="line" filename="file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php" lineno="369" state="enabled" hit_count="0" hit_value="0" id="980009"></breakpoint></response>
[98]
[98] <- breakpoint_set -i 18 -t exception -x *
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="18" id="980010"></response>
[98]
[98] <- run -i 19
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="19" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php" lineno="114" exception="ReflectionException"><![CDATA[Method suite does not exist]]></xdebug:message></response>
[98]
[98] <- stack_get -i 20
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="20"><stack where="ReflectionClass-&gt;getMethod" level="0" type="file" filename="file:///var/www/html/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php" lineno="114"></stack><stack where="PHPUnit\TextUI\TestRunner-&gt;getTest" level="1" type="file" filename="file:///var/www/html/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php" lineno="114"></stack><stack where="PHPUnit\TextUI\Command-&gt;run" level="2" type="file" filename="file:///var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php" lineno="183"></stack><stack where="PHPUnit\TextUI\Command::main" level="3" type="file" filename="file:///var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php" lineno="162"></stack><stack where="{main}" level="4" type="file" filename="file:///var/www/html/vendor/phpunit/phpunit/phpunit" lineno="61"></stack></response>
[98]
[98] <- run -i 21
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="21" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php" lineno="255" exception="Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException"><![CDATA[]]></xdebug:message></response>
[98]
[98] <- run -i 22
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="22" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php" lineno="137" exception="InvalidArgumentException"><![CDATA[View [405] not found.]]></xdebug:message></response>
[98]
[98] <- run -i 23
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="23" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php" lineno="112" exception="PHPUnit\Framework\ExpectationFailedException"><![CDATA[Expected status code 404 but received 405.
Failed asserting that false is true.]]></xdebug:message></response>
[98]
[98] <- run -i 24
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="24" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php" lineno="112" exception="PHPUnit\Framework\ExpectationFailedException"><![CDATA[Expected status code 404 but received 405.
Failed asserting that false is true.]]></xdebug:message></response>
[98]
[98] <- run -i 25
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="25" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php" lineno="112" exception="PHPUnit\Framework\ExpectationFailedException"><![CDATA[Expected status code 404 but received 405.
Failed asserting that false is true.]]></xdebug:message></response>
[98]
[98] <- run -i 26
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="26" status="stopping" reason="ok"></response>
[98]
[98] <- run -i 27
[98] Log closed at 2019-10-18 08:07:34
[98]

那么如何使xgebug成为我的测试函数签名?

So how I can make the xgebug the my test function signature?

推荐答案

我遇到了同样的问题.如果勾选了一切",则在调试侧栏的"Breakpoints"部分的左下角检查.取消勾选.

I was having the same problem. Check on your lower left, on "Breakpoints" section of the debug sidebar, if "Everything" is ticked. Untick it.

请查看以下屏幕截图,以了解如何取消选中它:

Look on the following screenshot for how to uncheck it:

这篇关于带有xdebug的PHpUnit在BaseTestRunner而不是实际测试处中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆