簡體   English   中英

PhpUnit在Symfony 2項目中的退出代碼255的PhpStorm失敗

[英]PhpUnit failing in PhpStorm w/ exit code 255 in Symfony 2 project

我無法讓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

編輯:以下是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

我遇到了同樣的問題,並在文檔中找到了以下解決方案: 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> 

因此,請檢查您的phpunit.xml.dist配置文件,並嘗試將絕對路徑添加到您的app-directory。

希望能幫助到你。

PhpStorm並不總是從項目根目錄實例化測試運行器,為了解決此問題,請在運行/調試配置中的“自定義工作目錄”下添加項目根目錄的絕對路徑。 這將節省您必須在phpunit.xml.dist配置中添加應用程序的絕對路徑,它還將確保可以找到任何相對路徑文件包括(例如JSON測試數據)。

使其工作的步驟(在PHPStorm 8.0.1中測試):

1)在 Preferences > PHP > PHPUnit 確保沒有為默認配置文件或默認引導程序文件設置任何內容。

2)通過 Command Line 小節 中的 Run > Edit Configurations > 進行自定義PHPUnit配置 ,並確保:

a)設置 Custom working directory: /absolute/path/to/vendor

b)選中“使用備用配置文件:”並將其設置為 /absolute/path/to/vendor/your_app/(sub_app_if_applicable)/phpunit.xml.dist

然后,您可以通過指定類和文件來運行套件中的任何測試類,或者只需選中“在配置文件中定義”以根據配置運行所有測試類。

我遇到了同樣的問題。 如果您使用的是yii2 / phpStorm,請嘗試在調試配置部分的“備用配置​​文件”下選擇codeception.yml而不是unit.yml

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM