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 run this:
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
You're free to use this package (it's MIT-licensed), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.
We publish all received postcards on our company website.
You can install this package globally like this
composer global require spatie/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 spatie/phpunit-watcher --dev
Locally installed you can run it with vendor/bin/phpunit-watcher watch
For performance reasons the package will create a .phpunit-watcher.cache.php
inside the directory where it is run. You should add an entry for that file in your global gitignore.
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.
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
fileMask: '*.php'
Want to pass some arguments to PHPUnit no problem, just tack them on:
phpunit-watcher watch --filter=it_can_run_a_single_test
Please see CHANGELOG for more information what has changed recently.
composer test
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
The MIT License (MIT). Please see License File for more information.