代码之家  ›  专栏  ›  技术社区  ›  Kristian Lunde

PHPUnit和Zend框架的代码覆盖率失败

  •  3
  • Kristian Lunde  · 技术社区  · 14 年前

    我对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
    
    

    我的朋友。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文件只是为了查看它是否是一个文件问题,但是在Library/Klunde目录下的下一个文件上会触发错误。

    我正在运行OSX雪豹,使用PHP5.3.1、XDebug 2.1.0beta3和PHPUnit 3.4.15

    我们将非常感谢所有的帮助和帮助。

    谢谢

    1 回复  |  直到 14 年前
        1
  •  2
  •   Anti Veeranna    14 年前

    添加一个 debug_print_backtrace() 打电话到你的Klunde_Auth的顶端。php,在类声明本身开始之前。

    然后再次运行testsuite,现在每次包含该文件时,您都会看到整个回溯,这将有助于您了解两次包含该文件的内容/位置。