Phpstorm and other IDEs allows you to run behat tests in debug mode.
But when it executes "Then I break" step it is not possible to press "enter" continue.
So "Then I break" step works only if you run tests using terminal.
But sometimes it is very useful to stop the process with "Then I break" and have a look into the browser during debugging.

Would be useful to set xdebug_breakpoint in "Then I break" if xdedug is enabled.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

a.milkovsky’s picture

Status: Active » Needs review
FileSize
961 bytes

See the attached patch

fago’s picture

I love the idea, however looks like xdebug_is_enabled() does not check for the right thing:
>Return whether stack traces would be shown in case of an error or not.

Maybe there is an alternative function which tells us whether xdebug is in debug mode?

a.milkovsky’s picture

FileSize
1.01 KB

I think function description might be misleading. (See http://xdebug.org/docs/all_functions)
xdebug_enable() - Enables stack traces. Enable showing stack traces on error conditions.
xdebug_is_enabled() - Returns whether stack traces are enabled. Return whether stack traces would be shown in case of an error or not.

I changed a little bit patch to detect if current output is terminal.

derickr’s picture

You should be able to call xdebug_break() even when Xdebug isn't running though, but you're right that xdebug_is_enabled() doesn't work here. I would need to add an argument to xdebug_is_enabled() so that you can request whether specific features are turned on. Please file a feature request at http://bugs.xdebug.org if you want!

a.milkovsky’s picture

@derickr, thank you for your comment. I agree that it is not so easy with xdebug_is_enabled().
You can see my last patch. I detect terminal and xdebug separately. For xdebug xdebug_break() function is called. If xdebug is not started, the function will be just ignored.

fago’s picture

Related: Very useful for debugging is https://github.com/DevinciHQ/devinci-behat-extension.