2011-09-30 65 views
2

我想讓PHPUnit在Netbeans中工作。我使用3.4.9,但拒絕工作,並建議升級到最新版本。我現在已經升級到3.5.15,當我運行它,我得到以下信息:PHPUnit集成到NetBeans 7

unrecognized option --log-xml 

我明白,這不是有效的日誌選項,但我不知道這是被設置或如何更改。我的phpunit.xml文件是:

<phpunit bootstrap="./application/bootstrap.php" colors="true"> 
    <testsuite name="Personal Development"> 
     <directory>./</directory> 
    </testsuite> 
    <filter> 
     <whitelist> 
      <directory suffix=".php">../application/</directory> 
      <exclude> 
       <file>../application/Bootstrap.php</file> 
       <file>../application/controllers/ErrorController.php</file> 
       <directory suffix=".phtml">../application/</directory> 
      </exclude> 
     </whitelist> 
    </filter> 


    <logging> 
     <log type="coverage-html" target="./log/report" charset="UTF-8" 
      yui="true" highlight="true" lowUpperBound="50" highLowerBound="80"/> 
     <log type="testdox-html" target="./log/testdox.html" /> 
    </logging> 
</phpunit> 

如何解決此錯誤?

+0

我假設它在phpunit被調用時通過,檢查執行的命令並查看是否有一些可以影響的配置。 – hakre

回答

3

爲了強制PHPUnit使用正確的文件,我必須右鍵單擊項目名稱,設置配置,自定義,PHPUnit,然後隱式指定引導程序和XML配置文件的位置。

1

我遇到了一個使用XAMPP,PHPUnit 3.5和NetBeans 7的類似問題。問題是,NetBeans出於某種原因始終將選項「--log-xml」傳遞給phpunit.bat,但該選項不存在於PHPUnit 3.5更多。

我的解決辦法是編輯PHPUnit的XML配置文件: C:\ XAMPP \ PHP \ PEAR \測試\ MIME_TYPE \測試\ phpunit.xml

(請注意,文件路徑依賴路徑的梨或PHPUnit的安裝位置)

我不得不追加一個新的節點,「記錄」:

<?xml version="1.0" encoding="utf-8"?> 
<phpunit strict="true" colors="true" 
     bootstrap="bootstrap.php" 
> 
<filter> 
    <whitelist> 
    <directory suffix=".php">../MIME/</directory> 
    </whitelist> 
</filter> 
<logging> 
    <log type="junit" target="c:/xampp/tmp/logfile.xml" logIncompleteSkipped="false"/> 
</logging> 
</phpunit> 

此更改後,NetBeans的不通過「--log-XML」選項了,但「--log-junit」選項對PHPUnit 3.5有效。 MyTests現在再次驗證。 :-)