How do I run PHP Unit Tests w/ XDEBUG from within PHPStorm [on Mac]?
Here are the steps/complete set of screenshots of a configuration that now works for me:
1) from command line ensure you can run buildkit -&gt; civibuild
$ civibuild create dmaster --type drupal-demo --civi-ver master --url http://dmaster.localhost --admin-user myuser --admin-pass mypass
2) from command line ensure you can run tests - that all is working properly
karins-macbook-pro:civicrm sysadmin$ pwd
/Applications/MAMP/htdocs/buildkit/build/dmaster/sites/all/modules/civicrm
$ cd /path/to/civicrm
$ env CIVICRM_UF=UnitTests phpunit4 ./tests/phpunit/CRM/AllTests.php

Installing dmastertes_7by9i schema

Installing dmastertes_7by9i database
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.

...............................................

.......
^X^C

3) Ensure you can fire up a http://d47.localhost/ in a browser and debug/set breakpoints anywhere in PHPStorm / step through code in your Drupal/CiviCRM code base - e.g.

4. PHPStorm: Preferences -&gt; Languages &amp; Frameworks -&gt; PHP:

5. PHPStorm: Preferences -&gt; Project: Directories:

6. PHPStorm: Preferences -&gt; Language &amp; Frameworks -&gt; PHP -&gt; PHPUnit:

7. PHPStorm: Run -&gt; Edit Configurations -&gt; Default -&gt; PHP Unit:

8. Run the test by right clicking on the test itself:

9. Et voila:


UPDATE JULY 2018
After updating buildkit:
cd ~/buildkit
git pull
./bin/civi-download-tools

I had to make some edits as some of the paths have changed. The edits I made are:
ad 4:

ad 5:

ad 7: note you want to Include parent environment variables

And we're up and running again:

UPDATE AUGUST 2020
After updating buildkit and PHPStorm -&gt; here's the new screenshots!





Running a test via the command line also using phpunit5 now:
karins-MBP:civicrm sysadmin$ env CIVICRM_UF=UnitTests phpunit5 --filter testSubmitWithTax ./tests/phpunit/CRM/Member/Form/MembershipRenewalTest
Parsing schema description /Applications/MAMP/htdocs/buildkit/build/dmaster/web/sites/all/modules/civicrm/xml/schema/Schema.xml
Extracting database information
Extracting table information
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
.                                                                   1 / 1 (100%)
Installing dmastercivi_rb7eb database
Time: 9.92 seconds, Memory: 58.50MB
OK (1 test, 18 assertions)