swoft使用phpunit之CodeCoverage

1.更改根目录下的phpunit.xml文件

  • 增加
<logging>
        <log type="coverage-html" target="./public/test/"/>
</logging>

2.为了避免swoole的检测xdebug警告,扩展注册的名称是sdebug,如果想使用Phpunit CodeCoverage,需要手动把xdebug的判断修改成sdebug
需要更改两个路径:
在这里插入图片描述
在这里插入图片描述
3.安装sdebug

git clone https://github.com/mabu233/sdebug.git
cd sdebug
./rebuild.sh

更改rebuid.sh配置
php-config的路径
在这里插入图片描述
php.ini(usr/local/php/etc/php.ini)添加zend_extension=“xdebug.so”

php -v 查看

PHP 7.2.0RC6 (cli) (built: Nov 23 2017 10:30:56) ( NTS DEBUG )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0-dev, Copyright (c) 1998-2017 Zend Technologies
        with Sdebug v2.x.x-dev, Copyright (c) 2002-2017, by Derick Rethans

若出来如上信息,说明成功

最后.使用

./vendor/bin/phpunit ./test/getFormInfoMiniTest.php --coverage-html ./public/test/
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
要安装和使用PHPUnit,您可以按照以下步骤进行操作: 1. 下载PHPUnit使用命令`wget https://phar.phpunit.de/phpunit.phar`下载PHPUnit。 2. 将PHPUnit设置为全局变量:使用命令`mv phpunit.phar /usr/local/bin/phpunit`将PHPUnit移动到/usr/local/bin目录下,这样您就可以在任何位置直接使用`phpunit`命令了。 3. 检查安装是否成功:在命令行中输入`phpunit --version`,如果正确显示PHPUnit的版本号,则表示安装成功。 4. 创建测试文件:在您的项目目录中创建一个名为`TestExample.php`的文件,并添加测试代码。 5. 运行测试:在命令行中进入到您的项目目录中,然后运行`phpunit TestExample.php`命令来执行测试。 6. 配置文件:如果您需要自定义PHPUnit的配置,可以在项目目录中创建一个名为`phpunit.xml`或`phpunit.xml.dist`的配置文件。如果您希望忽略当前目录下的配置文件,可以使用`--no-configuration`选项来跳过配置文件的加载。 通过按照上述步骤进行操作,您就可以成功安装和使用PHPUnit来进行PHP单元测试了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [PHPUnit简介及使用](https://blog.csdn.net/agonie201218/article/details/89675236)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [PHPUnit介绍及安装](https://blog.csdn.net/lg_lin/article/details/8073945)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值