PhpUnit在Symfony 2项目中的退出代码255的PhpStorm失败

gre*_*reg 6 php phpunit symfony phpstorm

我无法让phpunit在PhpStorm的Symfony项目中phpunit -c app工作- 在OSX终端中工作正常.

这是错误:

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
MyApp\MyBundle\Tests\Controller\MyControllerTest 
/Users/greg/Repos/MyApp/src/HvH/MyBundle/Tests/Controller/MyControllerTest.php

Testing started at 11:45 AM ...

Process finished with exit code 255
Run Code Online (Sandbox Code Playgroud)

编辑:以下是PHP日志中的错误:

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
Run Code Online (Sandbox Code Playgroud)

小智 6

我遇到了同样的问题,并在文档中找到了以下解决方案:http: //symfony.com/doc/current/book/testing.html#your-first-functional-test

要运行功能测试,WebTestCase类会引导应用程序的内核.在大多数情况下,这会自动发生.但是,如果您的内核位于非标准目录中,则需要修改phpunit.xml.dist文件以将KERNEL_DIR环境变量设置为内核目录:

<phpunit>
    <!-- ... -->
    <php>
        <server name="KERNEL_DIR" value="/path/to/your/app/" />
    </php>
    <!-- ... -->
</phpunit>
Run Code Online (Sandbox Code Playgroud)

因此,请检查您的phpunit.xml.dist配置文件,并尝试将绝对路径添加到您的app-directory.

希望能帮助到你.