Run PHPUnit tests on change(在更改时运行 PHPUnit 测试)
问题描述
每当磁盘上的文件发生更改时,我想运行我的 PHPUnit 测试(或至少其中的一部分).非常类似于您可以使用grunt watch"执行的操作.我有一个项目,其中我有 JS 和 PHP,并且正在使用 Grunt.在那里,我使用 grunt watch 让 PHPUnit 在我的 JS 测试之上运行.虽然这很好用,但在仅 PHP 的项目中执行此操作似乎非常麻烦.我需要引入 grunt,并添加对 node.js 的依赖.另外,我有很多这样的 PHP 项目.因此,需要一个更简单的解决方案.
I'd like to run my PHPUnit tests (or at least a subset of them) whenever a file changes on disk. Very similar to what you can do with "grunt watch". I have a project in which I have both JS and PHP, and am using Grunt. There I shell out to PHPUnit to have it run on top of my JS tests using grunt watch. While that works just fine, it seems like an awful lot of hassle to do this in a PHP only project. I'd need to introduce grunt, and add a dependency on node. Plus I have a lot of such PHP projects. A more simple solution is thus in order.
推荐答案
可以使用node watch
,挺甜的:
You can use node watch
which is quite sweet:
运行 npm init
设置一个包(需要一分钟),然后
Run npm init
to set up a package (takes a minute), then
npm install --save-dev watch
然后编辑您的 package.json
文件以包含这两个条目:
Then edit your package.json
file to include these two entries:
"scripts": {
"test": "bin/phpunit tests --color",
"test:watch": "watch 'npm run --silent test' ."
},
然后触发观看:
npm run test:watch
(归功于 这很有趣文章)
这篇关于在更改时运行 PHPUnit 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在更改时运行 PHPUnit 测试


- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Laravel 仓库 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01