Is it possible to debug PhpUnit tests with --process-isolation option?

风流意气都作罢 提交于 2019-12-05 04:45:53
SamHennessy

As stated in the comments on the question. The issue is that PHP Storm didn't support multiple parallel debugging sessions.

Artjom Kurapov

Go into PHPStorm Project Settings - PHP - Debug and set Xdebug to "force break at first line when script is outside the project".

It should break on some main() method and if you step over a couple of times (or press resume), it will reach your test.

This isn't a perfect answer, but you can surround any block of code with xdebug_start_trace() and xdebug_stop_trace() calls to generate a stack trace for a targeted block of code. I've used this to see exactly what it happening at specific points in my unit tests when testing other peoples' code.

class SampleTest extends PHPUnit_Framework_TestCase
{
    public function testBreakpoint()
    {
        xdebug_start_trace('/tmp/testBreakPointTrace');
        $a = 18;
        xdebug_stop_trace();
    }
}

Just keep in mind that any failures will cause PHPUnit's exception handler to step in and cause the stack trace to look a little strange. If you are getting an error, you can get a clean trace by adding an exit; call right after xdebug_stop_trace:

class SampleTest extends PHPUnit_Framework_TestCase
{
    public function testBreakpoint()
    {
        xdebug_start_trace('/tmp/testBreakPointTrace');
        $a = 18;
        xdebug_stop_trace();
        exit;
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!