How to setup PHPUnit in IntelliJ IDEA for Magento 2?

Magento 2 has an official manual for PHPStorm, but IntelliJ IDEA has some differencies in setup:

The latest IntelliJ IDEA (2016.2.5) does not have the «Use custom autoloader» option (used in the manual for PHPStorm).

You should use the «Path to phpunit.phar» option instead (marked with «1» on my screenshot).

Magento 2 uses an outdated PHPUnit version, and you should download the Phar distributive for it, and then specify its path in the «Path to phpunit.phar» field mentioned above.

The rest setup steps are the same as PHPStorm, read them in the official manual for PHPStorm.

An example of testing screen: