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:
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.