更改时运行PHPUnit测试 [英] Run PHPUnit tests on change

查看:70
本文介绍了更改时运行PHPUnit测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当文件在磁盘上更改时,我都想运行我的PHPUnit测试(或至少其中一部分).与"咕unt声"可以执行的操作非常相似.我有一个同时具有JS和PHP的项目,并且正在使用Grunt.我在那里使用PHP监视程序将其放到PHPUnit上,使其在我的JS测试之上运行.虽然这很好用,但在仅PHP项目中执行此操作似乎很麻烦.我需要引入grunt,并添加对node的依赖.另外,我有很多这样的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.

推荐答案

您可以使用非常可爱的节点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' ."
},

然后通过以下方式触发观看:

Then trigger the watching with:

npm run test:watch

(归功于这很有趣文章)

这篇关于更改时运行PHPUnit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆