![](/img/trans.png)
[英]PhpStorm 2018.2, PHPUnit 5.7.27. Process finished with exit code 255
[英]PHPStorm - Process finished with exit code 255
我正在嘗試在 Symfony 3 框架中進行單元測試。 這是我的配置;
這是我面臨的錯誤。
/Applications/MAMP/bin/php/php7.0.0/bin/php /private/var/folders/w9/cmwlplqx53x3slxkm4c1chx00000gn/T/ide-phpunit.php --bootstrap /Users/muhammetergenc/code/kampweb/phpunit.xml.dist --configuration /Users/muhammetergenc/code/kampweb/phpunit.xml.dist Tests\AppBundle\Controller\PersonTest /Users/muhammetergenc/code/kampweb/tests/AppBundle/Controller/PersonTest.php
Testing started at 3:04 PM ...
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="app/autoload.php">
<!-- <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="web/app_test.php">-->
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_DIR" value="app/" />
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
<exclude>
<directory>src/*Bundle/Resources</directory>
<directory>src/*/*Bundle/Resources</directory>
<directory>src/*/Bundle/*Bundle/Resources</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
Process finished with exit code 255
我的其他桌面上確實有相同的配置,而且工作正常。
今天我遇到了同樣的錯誤 - 255。在我的情況下,我沒有在 setUp 方法中聲明 CONSTANS。
我認為你有類似的東西。 嘗試使用 xdebug 找到它 - 它幫助了我。
就我而言,這是一個 php 錯誤設置問題。
我將 display_startup_errors 設置為“1”。 和 phpunit 報錯。
具體來說,在我的引導腳本中,我寫在下面。
ini_set('display_startup_errors', 1);
phpunit 報告我的require_once
運行時錯誤。
就我而言,這是一個內存問題。
在setUp()
方法中,我初始化了多個類屬性。
對我來說,修復是定義(覆蓋) tearDown()
方法以在每次測試后取消設置屬性。
protected function tearDown(): void
{
// clean memory
unset($this->foo);
unset($this->bar);
parent::tearDown();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.