thinkphp6+phpunit+mockery做单元测试
- 使用composer安装phpunit
composer require phpunit/phpunit --devcomposer require mockery/mockery --dev
- 配置composer
{ "autoload-dev": {
"psr-4": {
"tests\": "tests"
}
},
"scripts": {
"start": "php think run",
"post-autoload-dump": [
"@php think service:discover",
"@php think vendor:publish"
],
"coverage": "vendor\bin\phpunit --coverage-html=coverage",
"test": "vendor\bin\phpunit"
}
}
在项目目录下新建tests目录
运行
vendorinphpunit --generate-configuration
生成配置文件编写测试代码
运行
composer test
或composer coverage
参考了以下项目
https://github.com/friendsofthinkphp/think-jwt/
以上是 thinkphp6+phpunit+mockery做单元测试 的全部内容, 来源链接: utcz.com/z/518908.html