watch-phpunit

1.1.2 • Public • Published

watch-phpunit

A command line tool for PHPUnit.

  • test suite selection
  • live reload on file system changes

Usage

Usage: watch-phpunit [options]
Options:    
    -h, --help       Show help.
    -v, --version    Show version number.
    -c --config      Create or override the configuration file.

watch-phpunit will prompt you to pick a suite from the search result list:

watch-phpunit

Use keybord arrows to highlight your choice, then press <return>

After the tests execution, you can :

  • restart the suite
  • select another suite
  • add|remove a default suite
    • when a default suite is defined, you won't be asked to select a suite at startup
  • abort

The test suite will restart automatically when watched files are saved.

Installation

  • Localy
    npm i -D watch-phpunit
  • Globaly
    npm i -g watch-phpunit

Configuration

watch-phpunit.config.json example

{
    "suites": [
        {
            "pattern": "**/*.xml",
            "dirs": [
                "specs/config"
            ]
        }
    ],
    "watch": [
        {
            "pattern": "**/*.php",
            "dirs": [
                "."
            ]
        },
        {
            "pattern": "**/*.xml",
            "dirs": [
                "specs/config"
            ]
        }
    ],
    "cmd": "docker exec my-container phpunit",
    "pathMapping": {
        "source": "www",
        "target": "/var/www/html"
    }
}

Project structure:

├── docker-compose.yml
├── package.json
├── README.md
├── watch-phpunit.config.json
├── www
│   ├── specs
│   │   └── config
│   │       ├── autoload-back.php
│   │       ├── autoload-front.php
│   │       ├── back.xml
│   │       └── front.xml
...

npm scripts

  • Add script entries to package.json:
    {
        "scripts": {
            "wpu":"watch-phpunit",
            "wpu:config":"watch-phpunit -c"
        }
    }
  • Run the script:
    npm run wpu
    npm run wpu:config
  • Answer the questions

Package Sidebar

Install

npm i watch-phpunit

Weekly Downloads

1

Version

1.1.2

License

ISC

Unpacked Size

69.4 kB

Total Files

34

Last publish

Collaborators

  • raphael-volt