3

PHPunit と zend フレームワークのコード カバレッジ レポートに問題があります。phpunit テストを実行するたびに、コード カバレッジが失敗し、次のメッセージが返されます。


PHPUnit 3.4.15 by Sebastian Bergmann.

I.......III.I................................IIIIIIIIIIIIIII 60 / 93
IIII....I....I..II..II.....IIIIII

Time: 4 seconds, Memory: 22.25Mb

OK, but incomplete or skipped tests!
Tests: 93, Assertions: 174, Incomplete: 36.

Generating code coverage report, this may take a moment.PHP Fatal error:  Cannot redeclare class Klunde_Auth in /Users/kristianlunde/workspaces/private/klunde/Library/Klunde/Auth.php on line 9

Fatal error: Cannot redeclare class Klunde_Auth in /Users/kristianlunde/workspaces/private/klunde/Library/Klunde/Auth.php on line 9

私の phpunit.xml ファイルは次のようになります。


<phpunit bootstrap="./application/bootstrap.php" colors="true">
 <testsuite name="Klunde">
  <directory>./application/</directory>
  <directory>./Library/Klunde</directory>
 </testsuite>

 <filter>
  <whitelist>
   <directory suffix=".php">../application</directory>
   <directory suffix=".php">../Library/Klunde</directory>
   <exclude>
    <directory suffix=".phtml">../application/</directory>
    <file>../application/Bootstrap.php</file>
             <file>../application/controllers/ErrorController.php</file>
            </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>

私はやった

var_dump(get_included_files());

Authファイルの先頭にあり、失敗する前にファイルを複数回含めようとしました。

Klunde_Auth.php ファイルを削除して、1 つのファイルの問題かどうかを確認しようとしましたが、Library/Klunde ディレクトリの次のファイルでエラーが発生します。

PHP 5.3.1、XDebug 2.1.0beta3、および PHPUnit 3.4.15 で OSX Snow Leopard を実行しています。

すべてのヘルプと支援は高く評価されます。

ありがとう。

4

1 に答える 1

2

クラス宣言自体が開始する前に、Klunde_Auth.phpの先頭にdebug_print_backtrace()呼び出しを追加します。

次に、テストスイートを再度実行します。これで、ファイルが含まれるたびにバックトレース全体が表示されます。これは、ファイルが2回含まれている場所/場所を把握するのに役立ちます。

于 2010-09-08T15:00:27.060 に答える