对于PHP代码,基于
php-code-coverage、phpcov生成代码覆盖率报告:
php-code-coverage用来生成php代码覆盖率报告phpcov用来合并多请求覆盖率结果,生成报告结果
pecl install xdebug
在php.ini配置文件中增加配置:
[XDebug] xdebug.collect_params=on xdebug.collect_return=on xdebug.remote_autostart=on
composer install
在代码执行时,提前引入prepend.php文件;为降低对业务仓库的侵入,可在nginx里面配置,也可在PHP.ini里面配置。
nginx配置方法:
fastcgi_param PHP_VALUE "auto_prepend_file=/data/www/php-code-coverage/prepend.php";
php.ini配置方法:
auto_prepend_file=/data/www/php-code-coverage/prepend.php测试用例执行后,运行bash build.sh生成覆盖率报告。
参考文章: