From 863282a3c8ddd6ba0747a835501557a1fb8d9e08 Mon Sep 17 00:00:00 2001 From: Pierre Clavequin Date: Wed, 30 Apr 2025 21:16:55 +0800 Subject: [PATCH] test: re-run tests automatically with phpunit-watcher That is much more comfortable than restarting tests manually when a change is made The command to run tests during development remained unchanged: composer test --- .github/workflows/test.yml | 2 +- composer.json | 4 +++- phpunit-watcher.yml | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 phpunit-watcher.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 75f03e1..2a6ec38 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,4 +20,4 @@ jobs: extensions: curl, mbstring tools: composer:v2 - run: composer install - - run: composer test \ No newline at end of file + - run: composer test-ci \ No newline at end of file diff --git a/composer.json b/composer.json index 216888e..4be6524 100644 --- a/composer.json +++ b/composer.json @@ -51,6 +51,7 @@ "phpstan/phpstan": "^2.1", "phpunit/phpunit": "^9.6", "rregeer/phpunit-coverage-check": "^0.3.1", + "spatie/phpunit-watcher": "^1.23 || ^1.24", "squizlabs/php_codesniffer": "^3.11" }, "config": { @@ -61,7 +62,8 @@ "sort-packages": true }, "scripts": { - "test": "phpunit", + "test": "vendor/bin/phpunit-watcher watch", + "test-ci": "phpunit", "test-coverage": "rm -f clover.xml && XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage --coverage-clover=clover.xml && vendor/bin/coverage-check clover.xml 100", "test-server": "echo \"Running Test Server\" && php -S localhost:8000 -t tests/server/", "test-server-v2": "echo \"Running Test Server\" && php -S localhost:8000 -t tests/server-v2/", diff --git a/phpunit-watcher.yml b/phpunit-watcher.yml new file mode 100644 index 0000000..d31e912 --- /dev/null +++ b/phpunit-watcher.yml @@ -0,0 +1,13 @@ +hideManual: true +watch: + directories: + - tests + - flight + fileMask: '*.php' +notifications: + passingTests: false + failingTests: false +phpunit: + binaryPath: ./vendor/bin/phpunit + arguments: '--stop-on-failure' + timeout: 180 \ No newline at end of file