I wrote some API tests with Codeception's ApiGuy. Now I want to set breakpoints in my PhpStorm 7 for tests debugging, but have no idea how to start debug session after $ vendor/bin/codecept run
. I know about --debug
option, but it's not exactly what I want.
Do you have any idea? Thanks in advance!
I ran into the same problem. Seems that Codeception only comes with a command line tool, which cannot be debugged. I finally ended up writing my own PHP runner, which is basically a lite copy of the codeception
command executable.
Actually all you would have to do in Linux is to remove the shebang from the codeception
tool to run it as a PHP script. But since commands other then codeception run
are much less likely to be a subject of debugging, I've prepared a separate PHP script. It contains only the run
option:
<?php
/**
* Codeception PHP script runner
*/
require_once dirname(__FILE__).'/../vendor/codeception/codeception/autoload.php';
use Symfony\Component\Console\Application;
$app = new Application('Codeception', Codeception\Codecept::VERSION);
$app->add(new Codeception\Command\Run('run'));
$app->run();
After you get this done you can set up your debugging script like any other in PHPStorm. So go to the Select Run/Debug Configuration
> Edit Configurations...
:
Now Add New Configuration (Alt + Insert)
> PHP Script
. Then name the run configuration and select the file you created above. Remember to add the run
argument:
And that's it. Now you can run your tests from within the IDE and debug them as ordinary scripts.
I use the codecept.phar file and I find this one does work. just type this command in the console and then run the codeception tests:
export XDEBUG_CONFIG="idekey=session_name remote_host=localhost profiler_enable=1"
I would suggest to use
php -dxdebug.remote_enable=1 -dxdebug.remote_autostart=On -dxdebug.idekey=YOUR_KEY -dxdebug.remote_host=YOUR_IP ../vendor/bin/codecept run
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