For unittest
class SampleTest extends PHPUnit_Framework_TestCase
{
public function testBreakpoint()
{
$a = 18;
}
}
with breakpoint on line 5 "$a = 18;",
Running unittest with NO --process-isolation option stops script execution on the line 5, as expected. Running the same configuration WITH --process-isolation option does not stop execution on line 5.
The option --process-isolation runs every test in new process using 'proc_open' in runJob function in https://github.com/sebastianbergmann/phpunit/blob/3.6/PHPUnit/Util/PHP.php
Tested with PhpStorm 3 and vim 7 with debugger plugin. It allows to debug PHPUnit itself, but not testcases.
Is there any way to debug the child process created by PhpUnit using Xdebug? may be Zend Debugger?
As stated in the comments on the question. The issue is that PHP Storm didn't support multiple parallel debugging sessions.
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;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With