1.要引入phpunit
composer require phpunit/phpunit
2. 在根目录下添加bootstrap.php
引入vendor库
<?php
require __DIR__ . '/vendor/autoload.php'; // 路径取决于和vendor的相对位置
3.在composer.json
文件中配置自动加载的目录
"autoload": {
"psr-4": {
"AbstractFactory\\": "AbstractFactory/"
}
}
4.执行composer dump-autoload
5.执行测试脚本
phpunit --bootstrap bootstrap.php AbstractFactory\Test\AbstractFactoryTest
网友评论