t73biz/phpunit-watcher
Composer 安装命令:
composer require t73biz/phpunit-watcher
包简介
Automatically rerun PHPUnit tests when source code changes
关键字:
README 文档
README
Wouldn't it be great if your PHPUnit tests would be automatically rerun whenever you change some code? This package can do exactly that.
With the package installed you can do this:
phpunit-watcher watch
Here's how it looks like:
This will run the tests and rerun them whenever a file in the app, src or tests directory is modified.
Want to pass some arguments to PHPUnit? No problem, just tack them on:
phpunit-watcher watch --filter=it_can_run_a_single_test
In his excellent talk at Laracon EU 2017 Amo Chohan shows our phpunit-watcher in action.
Installation
You can install this package globally like this
composer global require t73biz/phpunit-watcher
After that phpunit-watcher watch can be run in any directory on your system.
Alternatively you can install the package locally as a dev dependency in your project
composer require t73biz/phpunit-watcher --dev
Locally installed you can run it with vendor/bin/phpunit-watcher watch
Usage
All the examples assume you've installed the package globally. If you opted for the local installation prepend vendor/bin/ everywhere where phpunit-watcher is mentioned.
You can start the watcher with:
phpunit-watcher watch
This will run the tests and rerun them whenever a file in the src or tests directory is modified.
Want to pass some arguments to PHPUnit? No problem, just tack them on:
phpunit-watcher watch --filter=it_can_run_a_single_test
Notes on interactive commands
When running phpunit-watcher from a Composer script, you may need to redirect input in order for the interactive commands to work and disabled the default timeout:
{
"scripts": {
"test:watch": [
"Composer\\Config::disableProcessTimeout",
"phpunit-watcher watch < /dev/tty"
]
}
}
On Windows, Currently, TTY is not being supported, so any interaction has been disabled. While watching for changes works,
any arguments for PHPUnit have to be provided when initially calling phpunit-watcher.
Customization
Certain aspects of the behaviour of the tool can be modified. The file for options may be named .phpunit-watcher.yml, phpunit-watcher.yml or phpunit-watcher.yml.dist. The tool will look for a file in that order.
If a config file does not exist in the project directory, the tool will check if a file exists in any of the parent directories of the project directory.
Here's some example content. Read on for a more detailed explanation of all the options.
watch: directories: - src - tests fileMask: '*.php' notifications: passingTests: false failingTests: false phpunit: binaryPath: vendor/bin/phpunit arguments: '--stop-on-failure' timeout: 180
Customize watched directories and files
You can customize the directories being watched by creating a file named .phpunit-watcher.yml in your project directory. Here's some example content:
watch: directories: - src - tests exclude: - lib fileMask: '*.php' ignoreDotFiles: true ignoreVCS: true ignoreVCSIgnored: false
See the documentation for Finder for more details.
If you experience performance delays with large repositories, try adding exclude entries for any large subdirectories that you don't need to watch. Enabling the ignore... options can also be helpful. It's also important to ensure you're also using the '*.php' file mask.
Desktop notifications
By default the tool will display desktop notifications whenever the tests pass or fail. If you want to disable certain desktop notifications update .phpunit-watcher.yml by adding a notifications key.
notifications: passingTests: false failingTests: false
Help messages
By default the tool will display a helper for keyboard actions after each run. You can hide these help messages by adding a hideManual key in the .phpunit-watcher.yml.
hideManual: true
Customize PHPUnit
Binary
By default the tool use vendor/bin/phpunit as default PHPUnit binary file, however, it may be useful to be able to customize this value for people who have a binary file in a different location.
You can specificy it in the .phpunit-watcher.yml config file. Here's an example:
phpunit: binaryPath: ./vendor/phpunit/phpunit/phpunit
Initial arguments
If you want to use pass the same arguments to PHPUnit everytime to watcher starts, you can specify those in the .phpunit-watcher.yml config file. Here's an example:
phpunit: arguments: '--stop-on-failure'
When starting the tool with some arguments (eg phpunit-watcher watch --filter=my_favourite_test) those arguments will get used instead of the ones specified in the config file.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
Credits
We started creating this package after reading this excellent article by Christoper Pitt
Interactive commands were inspired by Jest.
License
The MIT License (MIT). Please see License File for more information.
t73biz/phpunit-watcher 适用场景与选型建议
t73biz/phpunit-watcher 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 06 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「spatie」 「phpunit-watcher」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 t73biz/phpunit-watcher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 t73biz/phpunit-watcher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 t73biz/phpunit-watcher 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Automatically rerun PHPUnit tests when source code changes
Receive webhooks in Laravel apps
Easily optimize images using PHP
Store your application settings
Add tags and taggable behaviour to your Laravel app
Speed up a Laravel application by caching the entire response additions
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-30