Run PHPUnit tests on change

后端 未结 10 1675
星月不相逢
星月不相逢 2021-02-07 11:34

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

10条回答
  •  隐瞒了意图╮
    2021-02-07 12:04

    Maybe you can try phpunit-watcher. https://packagist.org/packages/spatie/phpunit-watcher

    First, to install phpunit-watcher with composer require spatie/phpunit-watcher --dev, and then, modify the composer.json to add an item in scripts property:

    {
        "scripts" : {
            "test" : "./vendor/bin/phpunit-watcher watch --bootstrap vendor/autoload.php tests/"
        }
    }
    

    Then, you can run test cases with: composer test.

    Sometimes, you should run composer run test --timeout=0, otherwise the process would be killed after 300 seconds.

提交回复
热议问题