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 测试


基础教程推荐
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01