Asked  7 Months ago    Answers:  4   Viewed   92 times

I created a phpunit test file , when I try to run it via phpstorm, I get the message:

Unable to attach test reporter to test framework or test framework quit unexpectedly 

seems the following command is executed:

 /usr/local/bin/php /private/var/folders/4b/qrnw7nbd6llgmhrss5rf1_880000gt/T/ide-phpunit.php  --configuration /Users/Shared/sites/pac/app/app/phpunit.xml.dist BackendControllerTest /Users/Shared/sites/pac/app/modules/Pac/Backend/Tests/Controller/BackendControllerTest.php
Testing started at 23:22 ...

Process finished with exit code 0

when i execute this via command line , i get much more output

PHPUnit 3.6.11 by Sebastian Bergmann.

...etc...

 FAILURES!
Tests: 2, Assertions: 2, Failures: 1.

seems phpunit isn't executed in phpstorm? shouldn't there be some sort of error message instead of finishing with exit code 0? Paths to php & phpunit (same) in phpstorms configuration should be ok (both installed via homebrew in /usr/local/bin, path added to phpstorm)

osx 10.7.4 php 5.3.14 PHPUnit 3.6.11

Thanks for helping me!
Matthias

 Answers

79

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
 
Nate
answered 7 Months ago
86

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario: http://confluence.jetbrains.com/display/PhpStorm/PHPUnit+Installation+via+Composer+in+PhpStorm

Related usability ticket: http://youtrack.jetbrains.com/issue/WI-18388

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
 
ojrac
answered 9 Months ago
38

PhpStorm has special integration script to run PHPUnit tests (all messages/progress indicators are transferred into GUI part where you can easily see what tests have passed and what did not etc).

PhpStorm's console does not support ANSI colors -- http://youtrack.jetbrains.com/issue/IDEA-69880 and related tickets.

But you can install Grep Console plugin and it will add support for ANSI colors (needs to be activated in Settings). I have tried it with PHPUnit and it worked -- not everything was colored (some of the codes were not recognized, but most worked). You can contact plugin author with not working parts if desired.

Saturday, May 29, 2021
 
Zeth
answered 7 Months ago
59

In order to have PHAR archive indexed by IDE it has to have .phar extension (that's a requirement).

The easiest solution is to place phpunit.phar somewhere in your project (usually it would be PROJECT_ROOT/vendor/ folder).

If having local copy is not desired (for whatever reason; although composer and other similar kind of tools (bower/npm/etc) are primarily aimed at keeping dependency stuff/packages locally), you may use symbolic links: either create a symbolic link to that file locally (e.g. PROJECT_ROOT/phpunit.phar --> /usr/bin/phpunit) .. or place a full copy (or such symbolic link) in separate folder somewhere on your disk and then reference it via PhpStorm's Settings | PHP | Include Paths functionality.

Saturday, September 18, 2021
 
kensil
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share