2013-03-02 76 views
7

我有以下測試文件,這是PHPUnit網站上的一個示例。PHPUnit在PHPStorm中不工作

<?php 

require_once 'PHPUnit/Autoload.php'; 

class StackTest extends PHPUnit_Framework_TestCase 
{ 
    public function testPushAndPop() 
    { 
     $stack = array(); 
     $this->assertEquals(0, count($stack)); 

     array_push($stack, 'foo'); 
     $this->assertEquals('foo', $stack[count($stack)-1]); 
     $this->assertEquals(1, count($stack)); 

     $this->assertEquals('foo', array_pop($stack)); 
     $this->assertEquals(0, count($stack)); 
    } 
} 
?> 

我試圖在PHPStorm 5.0運行它,但我得到了以下錯誤:

E:\wamp\bin\php\php5.3.13\php.exe C:\Users\<user>\AppData\Local\Temp\ide-phpunit.php --no-configuration StackTest E:\wamp\www\renting\tests\StackTest.php 
Testing started at 03:37 ... 

SCREAM: Error suppression ignored for 
Warning: require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in C:\Users\<user>\AppData\Local\Temp\ide-phpunit.php on line 166 

任何想法,爲什麼它要C:當我設置了包括路徑E: ?

回答

9

解決了!

似乎有一些依賴項的問題,特別是pear.symfony.com/Yaml。

這樣做解決了這個問題:

pear channel-discover pear.symfony.com 
pear install pear.symfony.com/Yaml 
pear channel-discover pear.phpunit.de 
pear install --alldeps pear.phpunit.de/PHPUnit 

的解決方案的想法來自:How do I correctly install PHPUnit with PEAR?

+0

只是想離開這裏了這一點:[爲PEAR安裝方法終止(https://github.com/sebastianbergmann/phpunit/wiki/End-of-Life-for-PEAR-Installation -方法) – 2016-12-15 11:06:03

1

我的問題是類似的 - 但我解決了這個問題,通過指向測試引導文件。然後,一切正常。