swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 788 forks source link

单元测试该怎么写,有没有详细一点的demo #1389

Open tianya441523 opened 3 years ago

tianya441523 commented 3 years ago

看了一下官方文档,完全没找到单元测试的那块内容。在swoft的test中找到文档,提示用php test/run.php -c phpunit.xml --testsuite unitTests 但没有详细的demo教程,能不能出一份呢?

phpwei commented 3 years ago

运行单元测试中/**

phpwei commented 3 years ago

Error: Call to a member function test() on null

phpwei commented 3 years ago

[ERROR] Coroutine internal error: The pool of App\Model\Entity\Users entity is not defined or empty At File /data/api/vendor/swoft/db/src/EntityRegister.php line 175

sakuraovq commented 3 years ago

看看 Travis ci 脚本就知道了 框架自己有单元测试的

XuanYi2018 commented 3 years ago

好的,最近我们争取把单元测试的文档补上。

zch513430014 commented 3 years ago

@phpwei 我也遇到了,请问您解决了吗

inhere commented 3 years ago

https://github.com/swoft-cloud/swoft-components 可以看各个组件的单元测试

例如 http-server 的测试: https://github.com/swoft-cloud/swoft-component/tree/master/src/http-server/test/unit

swoft 里面也提供了测试示例的 https://github.com/swoft-cloud/swoft/tree/master/test