How to debug Drupal 8 Functional tests with XDebug

Submitted by Frederic Marand on

The problem

While converting the old-style functional tests in the MongoDB project from WebTestBase to BrowserTestBase, I stumbled upon a problem: after following the instructions to run PHPunit tests from PhpStorm, doing step-by-step debugging in the IDE worked nicely, but then stopped at the first $this->drupalLogin(); call, returning a 404 after a very long delay, although the same call running without debugging worked normally. What could be going on ?