PHPUnit Watcher 使用教程
1. 项目的目录结构及介绍
PHPUnit Watcher 是一个用于自动重新运行 PHPUnit 测试的工具,当源代码发生变化时。以下是该项目的目录结构及其介绍:
phpunit-watcher/
├── bin/
│ └── phpunit-watcher
├── config/
│ └── phpunit-watcher.js
├── src/
│ ├── Commands/
│ │ └── WatchCommand.php
│ ├── Services/
│ │ └── Watcher.php
│ └── phpunit-watcher.php
├── tests/
│ └── TestCase.php
├── .gitignore
├── composer.json
├── LICENSE
├── README.md
└── phpunit.xml
bin/
: 包含可执行文件phpunit-watcher
。config/
: 包含配置文件phpunit-watcher.js
。src/
: 包含项目的源代码,包括命令和服务的实现。tests/
: 包含测试用例。.gitignore
: Git 忽略文件。composer.json
: Composer 依赖管理文件。LICENSE
: 项目许可证。README.md
: 项目说明文档。phpunit.xml
: PHPUnit 配置文件。
2. 项目的启动文件介绍
项目的启动文件位于 bin/
目录下,名为 phpunit-watcher
。这个文件是一个可执行脚本,用于启动 PHPUnit Watcher 工具。
#!/usr/bin/env php
<?php
require __DIR__.'/../vendor/autoload.php';
use Spatie\PhpUnitWatcher\Console\Commands\WatchCommand;
use Symfony\Component\Console\Application;
$application = new Application();
$application->add(new WatchCommand());
$application->run();
这个脚本首先加载 Composer 自动加载文件,然后创建一个 Symfony Console 应用程序实例,并添加 WatchCommand
命令,最后运行应用程序。
3. 项目的配置文件介绍
项目的配置文件位于 config/
目录下,名为 phpunit-watcher.js
。这个文件用于配置 PHPUnit Watcher 的行为。
module.exports = {
watch: [
'app',
'src',
'tests'
],
phpunit: {
binary: 'vendor/bin/phpunit',
arguments: []
}
};
watch
: 指定要监视的目录或文件。phpunit
: 包含 PHPUnit 的二进制文件路径和运行时参数。
通过修改这个配置文件,可以自定义 PHPUnit Watcher 监视的目录和 PHPUnit 的运行参数。
以上是 PHPUnit Watcher 项目的目录结构、启动文件和配置文件的介绍。希望这份教程能帮助你更好地理解和使用这个工具。