Getting xdebug to work with BrowserTestBase functional tests? I'm having a really difficult time trying to get XDebug working with my functional tests that extend from BrowserTestBase.

Does anyone have a working configuration in place for this?

I'm using PHPStorm (version 2016.2) for debugging and already have a working XDebug setup for standard unit tests. I've been initiating the tests from PHPStorm directly, but would certainly be happy running them from a terminal outside of PHPStorm if it works!

Here's what I've tried for running out outside of PHPStorm in a normal terminal:

export SIMPLETEST_BASE_URL=http://drupal8.dd:8083
export XDEBUG_CONFIG="idekey=PHPSTORM"
vendor/bin/phpunit --configuration core/phpunit.xml.dist /Users/bosborne/Projects/drupal8/modules/cas/tests/src/Functional/CasAdminSettingsTest.php


The tests run but my breakpoints are ignored.
BrowserTestBase and KernelTestBase use phpunit's 'run in separate process' feature which generates a new temporary php file from a template and then executes that. The output is provided as serialized php object which is then read back into the main thread an unserialized to yield the results.

So at present that makes using Xdebug fairly difficult.

We probably should open an issue to look at shipping our own template that support Xdebug.

In the meantime my suggestion would be to use outputting, you can use the standard approaches like var_export, print_r, echo etc or you can use $this-&gt;htmlOutput($something_you_need_to_debug); which then shows up amongst the other HTML output.

Then run your tests with -printer="\Drupal\Tests\Listeners\HtmlOutputPrinter"

This requires the BROWSERTEST_OUTPUT_DIRECTORY environment variable to be set, see core's phpunit.xml.dist for info on how to configure that.