php单元测试

单元测试的工具主要有 PHPUNIT,PHPUNIT2和SimpleTest三种。其中PHPUNIT在功能上很简单,不算完善;PHPUNIT2是专门为PHP5写的单元 测试工具,在结构和功能上都向Junit看齐;而SimpleTest则是一套非常实用的测试工具,其中的webTest支持对web程序界面的测试,



SimpleTest

https://github.com/simpletest/simpletest
https://betheme.net/news/txtlist_i160756v.html?action=onClick



phpunit

http://www.phpunit.cn/
https://zhuanlan.zhihu.com/p/97301928?from=singlemessage
https://www.jb51.net/article/155234.htm

#安装8.0 >php4

#安装10 php需要>8.1
https://phpunit.de/getting-started/phpunit-10.html
composer require --dev phpunit/phpunit ^10
./vendor/bin/phpunit --version

PhpUnit9 php7.3-php7.4

#安装9.0 >php7.3
https://phpunit.de/getting-started/phpunit-9.html
composer require --dev phpunit/phpunit ^9
./vendor/bin/phpunit --version

windows下模式:
下载 https://phar.phpunit.de/phpunit-9.phar 放到网站根目录
php phpunit.phar --version #获取版本
php phpunit.phar tests 运行单元测试
php phpunit.phar --bootstrap src/Email.php tests/EmailTest #单类测试

在网站下新建tests目录 
所有测试类放在tests目录下,执行时自动调用测试