thinkphp5单元测试

单元测试,tp5的单元测试

单元测试官方文档地址:https://phpunit.readthedocs.io/zh_CN/latest/writing-tests-for-phpunit.html

1. 安装单元测试依赖包

我的thinkphp版本为 5.0.23
如果直接使用

composer require topthink/think-testing

会报错

Using version ^2.0 for topthink/think-testing
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

官方文档有一句
https://www.kancloud.cn/manual/thinkphp5/182511

官方的5.0版本的扩展库版本号都是1.*,2.0版本均为ThinkPHP5.1版本专用。

我们指定版本号 v1.0,命令如下,然后安装完成

composer require topthink/think-testing 1.*

2. 编写测试代码

2.1 修改测试代码

测试文件路径 : tp5/tests/

更改:TestCase.php

protected $baseUrl = 'http://www.test.com'; //更换成你本地的host域名

更改 ExampleTest.php

public function testBasicExample()
{
   
    $this->
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值