phpunit 单元测试框架-代码覆盖率

"phpize not found" 的解决办法: apt-get install php5-dev

 

http://jeffreysambells.com/2010/04/08/reporting-code-coverage-with-phpunit-and-xdebug

--------------------------------------------------------------------------------------

As a follow up to my previous post about debugging php I slightly changed the process and installed XDebug instead of Zend Debugger. This was mainly so that I could generate nice code coverage reports for my unit tests–and it was easy to setup.

To install xdebug all I had to do was:

% port install php5-xdebug

and then I edit my previous ini file to use xdebug instead:

zend_extension=/opt/local/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.remote_enable=on
xdebug.default_enable=on
xdebug.remote_autostart=on
xdebug.remote_host=127.0.0.1,192.168.0/24,10.37.129.2,10.211.55.2

The only other change was that I selected XDebug instead of Zend Debugger as the engine in the debug profile I had previously setup in Zend Studio.

With XDebug, the debugging in Zend Studio is the same however I can now generate nice code coverage reports for my PHPUnit tests:

phpunit --coverage-html ./report MyTests.php

The report lets you view each individual file that was included in the execution:

Note: if you’re using this you may want to increase the memory assigned to your command line PHP ini file. The report generation is a memory hog so I bumped mine to 512MB just to be safe.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值