Debugging a custom module with XDebug and PHPUnit
xdebug must be added in the PHP env. Acquia Dev Desktop, DrupalVM, Vlad and other VMs come with it out of the box. As for setting the connection up, IDEs like PHPStorm, Atom and VSCode have walkthroughs on how to do that.

For PHPUnit in Drupal 7, it is doable, but not easy. There are a few articles out there that can show you how, but they may be dated. There are two paths, using SimpleTest, and using PHPUnit on it's own.

See:


https://www.lullabot.com/articles/write-unit-tests-for-your-drupal-7-code-part-1
https://www.drupal.org/node/811254
https://tlattimore.com/blog/using-phpunit-with-drupal-7/
https://www.previousnext.com.au/blog/drupal-8-now-phpunit-tests-drupal-7
http://patshaughnessy.net/2008/12/12/writing-your-first-phpunit-test-in-drupal
https://devblog.more-onion.com/content/writing-unit-tests-drupal-7
DrupalUnitTestCase


To be honest, I got going with the articles from 2008 and 2012 respectively. It requires a bootstrap file (that requires and bootstraps Drupal) that you can require in your unit test classes - this allows you to use PHPUnit bare metal.

However, you should really evaluate the tests you are doing. If they truly are unit tests and you're familiar and comfortable with PHPUnit, go for it. But if you can achieve it via SimpleTest, that may be an easier road in Drupal 7. DrupalUnitTestCase is meant for that.