Vitaly Chirkov Vitaly Chirkov - 2 years ago 535
PHP Question

Debugging Codeception tests with Xdebug

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
option, but it's not exactly what I want.

Do you have any idea? Thanks in advance!

Answer Source

I ran into the same problem. Seems that Codeception comes only with command 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 separate PHP script. It contains only the run option:

 * 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'));


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...:

Edit Configurations...

Now Add New Configuration (Alt + Inssert) > PHP Script. Then name the run configuration and select the file you created above. Remember to add the run argument:

enter image description here

And that's it. Now you can run your tests from within IDE and debug them as ordinary scripts.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download