[英]0% code coverage with PHPUnit
I'm running module tests with PHPUnit and want to get coverage reports on the tests. 我正在使用PHPUnit运行模块测试,并希望获得有关测试的覆盖率报告。 I've successfully been doing this in the past, but somehow i cannot get it working again and I have no idea why it's not working any longer.
我过去已经成功完成了此操作,但是不知何故我无法使其再次正常工作,我也不知道为什么它不再有效。 The only difference is that i now run PHP 5.4 instead of 5.3.
唯一的区别是我现在运行的是PHP 5.4而不是5.3。
The tests are run in an Ant build file with the exec command: 使用exec命令在Ant构建文件中运行测试:
<exec dir="${basedir}" executable="phpunit.bat" failonerror="${test.failonerror}">
<arg value="--log-junit" />
<arg value="${test.phpunit.log}" />
<arg value="--coverage-clover" />
<arg value="${test.phpunit.coverage.log}" />
<arg value="--bootstrap" />
<arg value="${test.phpunit.bootstrap}" />
<arg value="${test.phpunit.testdir}" />
</exec>
Here is a snippet of the Ant log when i run my tests: 这是我运行测试时的Ant日志片段:
module-test-php:
[exec] PHPUnit 3.6.12 by Sebastian Bergmann.
[exec] .............
[exec] Time: 5 seconds, Memory: 8.75Mb
[exec] OK (13 tests, 113 assertions)
[exec] Generating code coverage report in Clover XML format ... done
From the log, it appears that coverage reporting should work, but when I open the report, all I get is this 从日志中看,覆盖率报告应该可以工作,但是当我打开报告时,得到的只是这个
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1344329670">
<project timestamp="1344329670">
<metrics files="0" loc="0" ncloc="0" classes="0" methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="0" coveredstatements="0" elements="0" coveredelements="0"/>
</project>
</coverage>
Is there some setting I'm missing here or why do I get zero coverage? 我在这里缺少某些设置吗?为什么我的覆盖率是零?
Update 更新资料
I did some more testing and found bug relating to phar archives. 我做了一些测试,发现了与phar档案有关的bug。 The issue has been reported.
该问题已报告。
https://github.com/sebastianbergmann/php-code-coverage/issues/107 https://github.com/sebastianbergmann/php-code-coverage/issues/107
Codecoverage is about the source-code form. Codecoverage与源代码形式有关。 The source-code form is the variant of the software you make changes to.
源代码形式是您要更改的软件的变体。
A phar file is an archive. phar文件是一个存档。 Similar to PHP code encoded by Zend Encoder or Ioncube Encoder or even APC, code coverage can not work for these and more importantly: Code coverage as a metric does not make any sense to work for these files.
与Zend Encoder或Ioncube Encoder甚至APC编码的PHP代码类似,代码覆盖率不适用于这些代码,更重要的是:代码覆盖率作为度量标准对这些文件没有任何意义。
So you might just wonder, but wonder twice and think about why it is this way. 因此,您可能只是想知道,但是想知道两次,然后思考为什么会这样。 Try to find an explanation in your own words why reporting code-coverage for phar files is of no use.
尝试用自己的话找到一种解释,为什么报告phar文件的代码覆盖率没有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.