Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to run unit tests in PHPStorm's IDE

When I run vendor/bin/phpunit my tests all run successfully. However, when I right click on a tests file and click "Run tests" I end up seeing:

/usr/local/bin/php -dxdebug.coverage_enable=1 /private/var/folders/bj/t2w187x158g7rgghctgknwb80000gn/T/ide-phpunit.php --coverage-clover /Users/bkuhl/Library/Caches/WebIde70/coverage/services$tests.coverage --no-configuration /Users/bkuhl/Projects/myproject/services/app/tests Testing started at 3:09 PM ...  Fatal error: Class IDE_PHPUnit_Framework_TestListener contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (PHPUnit_Framework_TestListener::addRiskyTest) in /private/var/folders/bj/t2w187x158g7rgghctgknwb80000gn/T/ide-phpunit.php on line 504 PHP Fatal error:  Class IDE_PHPUnit_Framework_TestListener contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (PHPUnit_Framework_TestListener::addRiskyTest) in /private/var/folders/bj/t2w187x158g7rgghctgknwb80000gn/T/ide-phpunit.php on line 504 Call Stack:     0.0008     340040   1. {main}() /private/var/folders/bj/t2w187x158g7rgghctgknwb80000gn/T/ide-phpunit.php:0  PHP Stack trace: PHP   1. {main}() /private/var/folders/bj/t2w187x158g7rgghctgknwb80000gn/T/ide-phpunit.php:0  Process finished with exit code 255 

I have PHPStorm configured to use path/to/vendor/autoload.php

enter image description here I've temporarily changed the path of this directory for the purpose of this screenshot, but it is a perfectly valid path.

Has anyone run into issues using PHPStorm's ability to run your tests?

composer.json:

"require-dev": {     "way/generators": "dev-master",     "way/laravel-test-helpers": "dev-master",     "mockery/mockery": "*",     "codeception/aspect-mock": "*",     "phpunit/phpunit": "3.9.*@dev" }, 
like image 910
Webnet Avatar asked Jan 28 '14 20:01

Webnet


2 Answers

PhpStorm uses wrapper/helper script when executing PHPUnit tests (for integration purposes: monitor execution progress, stack trace etc).

At the moment that helper script does not support PHPUnit 3.8 or 3.9 -- only 3.7 and below.

Corresponding ticket: http://youtrack.jetbrains.com/issue/WI-21666 -- watch it (star/vote/comment) to get notified when it will be resolved.

P.S.
This issue is now fixed and fix will be available in next public EAP build (newer than current 134.1456).

like image 154
LazyOne Avatar answered Sep 17 '22 13:09

LazyOne


Another solution: Set

"phpunit/phpunit": "3.7" 

in composer.json

and run

composer update  

Then the issue will be resolved.

this worked for me also...

IntelliJ IDEA won't run PHPUnit 4.0 tests

like image 31
Dinar Avatar answered Sep 18 '22 13:09

Dinar