hot/phpunit-runner

该库允许监控 PHPUnit 测试

dev-master 2015-06-26 11:06 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:39:57 UTC


README

要求:php、phpunit、git、find

PHP 类和测试的监视器

bin/hot-phpunit-runner --config=app/phpunit.xml --watch

  • 当你更改实体 XXXClass 时,此监视器会查找并运行此实体的测试。
  • 当你更改实体 XXXClassTest 的测试时,此监视器也会运行此测试。
PHPUnit HotRunner has been started


> phpunit -c app/phpunit.xml ./src/.../....../XXXClassTest.php

PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from /Users/slava/project/xxx/app/phpunit.xml

....

Time: 1 second, Memory: 10.00Mb

OK (4 tests, 9 assertions)


[OK]

[注意] 如果你没有选项地运行 bin/hot-phpunit-runner,则将根据 git status 运行所有测试(或实体的测试)(一次)。请注意,运行器下次不会运行测试。(结果为监视器缓存)

默认运行如下

  • bin/hot-phpunit-runner --watch
  • bin/hot-phpunit-runner --config=app/phpunit.xml --watch

选项

 --config=app/phpunit.xml # custom phpunit config file
 --phpunit-options="-c app/ --testdox" # custom phpunit options (alternative for `--config`)
 --phpunit-bin=bin/phpunit # custom path to phpunit
 --watch # watcher mode
 --period=2 # sec. watcher period
 --clean # this option remove cached result and re-test full
 --test-similarity=100 # percentage of similarity 0..100 (entity vs test)
 --coverage=coverage.xml # collect coverage and write Clover xml
 --on-pass="echo 'pass callback';" # CLI command after pass
 --on-fail="echo 'fail callback';" # CLI command after fail
 --notify # notifications # OSX / UBUNTU notifications

安装

工作流程

  1. bin/hot-phpunit-runner --watch # 默认监视器
  2. bin/hot-phpunit-runner --config=app/phpunit.xml --watch # 带有 PHPUnit 配置文件
  3. bin/hot-phpunit-runner --config=app/phpunit.xml --phpunit-bin=bin/phpunit --watch # 带有自定义 phpunit
  4. bin/hot-phpunit-runner --clean # 清除缓存并重新测试更改集(监视器运行时)
  5. bin/hot-phpunit-runner --config=app/phpunit.xml --watch --period=1 # 带有 phpunit 配置的热监视器,带有 --period=1
  6. bin/hot-phpunit-runner --config=app/phpunit.xml --watch & # 带有 phpunit 配置文件和 &(后台进程)
  7. bin/hot-phpunit-runner --watch --test-similarity=50 # 带有 --test-similarity=50 的默认监视器 # 监视器找不到我的测试。我需要降低相似度。
  8. bin/hot-phpunit-runner --options="-c app/ --testdox" --watch # 带有 --options="-c app/ --testdox" 的监视器 # 带有自定义 PHPUnit 选项
  9. bin/hot-phpunit-runner --config=app/phpunit.xml --coverage=coverage.xml --watch # 带有 --config=app/phpunit.xml --coverage=coverage.xml。仅收集更改的覆盖率
  10. bin/hot-phpunit-runner --notify --watch # OSX / UBUNTU 通知

PhpStorm

在 PhpStorm 中突出显示覆盖率

bin/hot-phpunit-runner --config=app/phpunit.xml --coverage=coverage.xml --watch # 需要 --config=app/phpunit.xml PHPUnit 配置文件,在这种情况下,运行器将收集更改的覆盖率

插件: 下载 wiki 主页

PhpStorm settings

PhpStorm highlight

PhpStorm highlight

通知

bin/hot-phpunit-runner --notify --watch

osx notification

ubuntu notification

--notify 有依赖项