paliarush/magento2-vagrant-for-developers

Cannot run unit tests from PHPStorm on Magento 2.2.

centerax opened this issue · 3 comments

Problem:
Cannot run tests from PHPStorm.

Magento version: 2.2.2
PHP Unit version: 6.2.4

Error I get.
sftp://vagrant@127.0.0.1:3173/usr/bin/php /home/vagrant/.phpstorm_helpers/phpunit.php --configuration /Users/pablo/Vagrant/magento2/vagrant-magento-22/magento2ce/dev/tests/unit/phpunit.xml /Users/pablo/Vagrant/magento2/vagrant-magento-22/magento2ce/app/code
Testing started at 10:14 AM ...

Fatal error: Class 'PHPUnit_TextUI_ResultPrinter' not found in /home/vagrant/.phpstorm_helpers/phpunit.php on line 253

@centerax I just ran into this problem myself. For whatever reason, PhpStorm is running the old class versions of phpunit in /home/vagrant/.phpstorm_helpers/phpunit.php. I kept messing with the configuration and suddenly it ended up working. If you want, you could try these steps and see if it works for you...might be a workaround for now:

  1. SSH into the box and go to /home/vagrant/.phpstorm_helpers/ a run cp phpunit.php phpunit.php.bak
  2. Try and run a test from PhpStorm, you should get the error that /home/vagrant/.phpstorm_helpers/phpunit.php doesn't exist
  3. Go to Preferences > Languages & Frameworks > PHP > Test Frameworks and click on the + button
  4. Choose PHPUnit by Remote Interpreter and set the CLI interpreter to the box's name
  5. Select Use Composer autoloader and set the path to <install dir>/magento2ce/vendor/autoload.php
  6. Set the Test Runner "Default configuration file" to <install dir>/magento2ce/dev/tests/unit/phpunit.xml

Note: the <install dir> is copied to the box using the path to where it's installed on the host. If you're on a Mac, the install dir on the box will be /Users/<username>/<path to git clone location>.

Hopefully that'll work for you!

thanks @nfourteen I will try that :)

@nfourteen thanks for the suggested solution, added current issue to the FAQ list in the readme.