[PHPUnit]-01 使用
安装
composer require --dev phpunit/phpunit ^7
使用例子
-
composer init -> composer.json
-
创建文件和命令
touch phpunit.xml
mkdir tests/Unit
touch app/Email.php项目的编配信息: https://phpunit.readthedocs.io/zh_CN/latest/organizing-tests.html#xml
phpunit.xml
colors="true" 表示测试结果会高亮显示,
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php" colors = "true" verbase="true" stopOnFailute="false">
<testsuites>
<testsuite name="Unit">
<directory>./tests/Unit</directory>
</testsuite>
</testsuites>
</phpunit>
- psr4 自动加载
"autoload": {
"psr-4": {
"App\\": "app/"
}
},

浙公网安备 33010602011771号