PHPUnit 和 Zend Framework 的代码覆盖率失败
我对 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 文件的顶部执行了 a 操作,它在失败之前多次尝试包含该文件。
我还尝试删除 Klunde_Auth.php 文件,只是为了看看它是否是一个文件问题,但随后 Library/Klunde 目录中的下一个文件会触发错误。
我正在运行 OSX Snow Leopard,带有 PHP 5.3.1、XDebug 2.1.0beta3 和 PHPUnit 3.4.15
所有帮助和帮助将不胜感激。
谢谢。
I have some issues with code coverage reports in PHPunit and the zend framework. Whenever I run a phpunit test the code coverage fails returning the following message:
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
My phpunit.xml file looks like this:
<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>
I did a
var_dump(get_included_files());
at the top of the Auth file and it did try to include the file more than once before it failed.
I have also tried to remove the Klunde_Auth.php file just to see if it was a one file issue, but then the error is triggered on the next file in the Library/Klunde directory.
I am running OSX Snow Leopard, with PHP 5.3.1, XDebug 2.1.0beta3 and PHPUnit 3.4.15
All help and assistance will be highly appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加 debug_print_backtrace() 调用到顶部您的 Klunde_Auth.php,在类声明本身开始之前。
然后再次运行测试套件,现在您将在每次包含文件时看到整个回溯,这应该可以帮助您弄清楚它被包含的内容/来自哪里两次。
add a debug_print_backtrace() call to the top of your Klunde_Auth.php, before the class declaration itself starts.
Then run the testsuite again, now you will see the whole backtrace each time the file is included, this should help you to figure out what/from where it is being included twice.