Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
881 views
in Technique[技术] by (71.8m points)

php - PhpUnit failing in PhpStorm w/ exit code 255 in Symfony 2 project

I'm having trouble getting phpunit working inside of a Symfony project in PhpStorm - phpunit -c app works fine in the OSX terminal.

Here is the error:

Unable to attach test reporter to test framework of test framework quit unexpectedly
/Applications/MAMP/bin/php/php5.4.4/bin/php/private/var/folders/4l/hw8g4qlj6nnc37lfkc6hcj7w0000gn/T/ide-phpunit.php --bootstrap
/Users/greg/Repos/MyApp/app/bootstrap.php.cache --configuration    
/Users/greg/Repos/MyApp/app/phpunit.xml.dist
MyAppMyBundleTestsControllerMyControllerTest 
/Users/greg/Repos/MyApp/src/HvH/MyBundle/Tests/Controller/MyControllerTest.php

Testing started at 11:45 AM ...

Process finished with exit code 255

Edit: Here is the error from the PHP log:

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'The "app/" directory does not exist.' in /Users/greg/Repos/MyApp/vendor/symfony/symfony/src/Symfony/Component/Finder/Finder.php:650
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I ran into the same issue and found the following solution in the documentation: http://symfony.com/doc/current/book/testing.html#your-first-functional-test

To run your functional tests, the WebTestCase class bootstraps the kernel of your application. In most cases, this happens automatically. However, if your kernel is in a non-standard directory, you'll need to modify your phpunit.xml.dist file to set the KERNEL_DIR environment variable to the directory of your kernel:

<phpunit>
    <!-- ... -->
    <php>
        <server name="KERNEL_DIR" value="/path/to/your/app/" />
    </php>
    <!-- ... -->
</phpunit>

So check your phpunit.xml.dist configuration file and try to add the absolute path to your app-directory.

Hope it helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...