2011-09-04 49 views
2

我正在關注在0123nd上編寫Zend Framework之上的單元測試。視頻和其他一些源之間,我phpunit.xml如下所示:爲什麼PHPUnit不接受XML定義的測試套件?

<?xml version="1.0" encoding="UTF-8"?> 
<phpunit bootstrap="./application/bootstrap.php" colors="true"> 

    <testsuites> 
     <testsuite name="RefreshTests"> 
      <directory>./</directory> 
     </testsuite> 
    </testsuites> 

    <filter> 
     <whitelist> 
      <directory suffix=".php">../application</directory> 
     </whitelist> 
     <exclude></exclude> 
    </filter> 

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

</phpunit> 

不幸的是,當我試圖用這個文件運行PHPUnit的,而我可以確認的是,「boostrap.php」文件並運行,我在運行時出現此錯誤:

PHPUnit_Framework_Exception:無法打開「RefreshTests.php」和「RefreshTests.php」。在線102上的C:\ Program Files(x86)\ php \ pear \ PHPUnit \ Util \ Skeleton \ Test.php

這似乎表明PHPUnit正在尋找一個基於我命名測試的文件以便找到要運行的測試,而不是尊重我希望將其運行在整個目錄中。儘管如此,PHPUnit's documentation quite explicitly says that defining a test suite this way is allowed.

我做了什麼不正確?

+0

可能是Windows的問題。你使用的是什麼版本的phpunit?梨分佈可能已過時 –

+0

錯誤看起來像測試的路徑不正確,或沒有測試可用(你有文件與前綴測試?,例如ClassTest.php?) – opHASnoNAME

+0

是啊,你可以把github上的文件? –

回答

3

該錯誤表示phpunit在遞歸掃描時無法在"."目錄中找到任何測試類。

如果找不到任何測試文件,它會嘗試打開一個名稱與testsuite類似的.php文件。因此錯誤。

確保您TestClasses在Test.php結束或添加suffix=".php"(或其他),以您的<directory>代碼,並確保該文件包含一個類,在Test也結束。

相關問題