Tool that aids PHPUnit and PCOV
Running tests takes a lot of time, and generating test coverage also takes a significant amount of time. This tool might be useful in such situations.
Important
vendor/bin/phpunit and pcov are required.
e.g. sudo apt-get update && sudo apt-get install phpX.Y-pcov (X.Y is the PHP version)
- Select test files to run,
- Select files for which you want to generate coverage reports (HTML),
- You might be able to execute steps 1 and 2 easily and quickly. Probably, probably..
Files located in tests/ directory.
Files located in src/ or app/ directory.
brew install ddddddO/tap/pucogo install github.com/ddddddO/puco/cmd/puco@latest$ puco --help
Usage: puco [options]
puco
Options:
-repeat
This flag starts with data selected by the most recently executed puco.
Example:
puco # normal launch
puco --repeat # launch using the most recent data
Processing description:
1. You can select multiple test files to run (fuzzy search available).
2. You can select multiple PHP files for which you want to calculate coverage (fuzzy search available).
3. Calculate the longest matching directory path from multiple selected PHP file paths in step 2
- ※ Note that only the PHP file paths selected in step 2 are not the target for coverage calculation. Instead, the directory path under the longest match calculated becomes the target for coverage calculation. If there are numerous PHP files under the calculated directory path, the coverage calculation process may become slow.
4. If Steps 1 and 3 and an existing phpunit.xml are present, generate phpunitxml_generated_by_puco.xml based on them.
5. Assemble and execute the php command.
6. Coverage reports are generated under the coverage-puco directory.
WARNING:
When puco is run for the first time, a configuration file named ~/.config/puco.toml is created. This configuration file contains a key: CommandToSpecifyBeforePHPCommand. It specifies that the PHP command should be executed via the Docker command. If you wish to execute the PHP command directly, please set the value of this key to "" or delete this entire line.
$- You can select multiple test files to run (fuzzy search available).
- You can select multiple PHP files for which you want to calculate coverage (fuzzy search available).
- Calculate the longest matching directory path from multiple selected PHP file paths in step 2
- ※ Note that only the PHP file paths selected in step 2 are not the target for coverage calculation. Instead, the directory path under the longest match calculated becomes the target for coverage calculation. If there are numerous PHP files under the calculated directory path, the coverage calculation process may become slow.
- If Steps 1 and 3 and an existing
phpunit.xmlare present, generatephpunitxml_generated_by_puco.xmlbased on them. - Assemble and execute the
phpcommand. - Coverage reports are generated under the
coverage-pucodirectory.
Warning
※ When puco is run for the first time, a configuration file named ~/.config/puco.toml is created.
This configuration file contains a key: CommandToSpecifyBeforePHPCommand. It specifies that the PHP command should be executed via the Docker command. If you wish to execute the PHP command directly, please set the value of this key to "" or delete this entire line.
Processing of PuCo (ja)
- 実行したいテストファイルを複数選択できます(fuzzyに検索可能)
- カバレッジを算出したいPHPファイルを複数選択できます(fuzzyに検索可能)
- 2で複数選択されたPHPファイルパスから最長一致のディレクトリパスを計算
- ※ 2で選択された各PHPファイルパスのみがカバレッジ計算対象では無く、算出された最長一致のディレクトリパス配下がカバレッジ算出対象になることに注意してください。算出されるディレクトリ配下に多数のPHPファイルがある場合、カバレッジ計算処理が遅くなるかもしれません。
- 1と3と既存の
phpunit.xmlがあれば、それらを元にphpunitxml_generated_by_puco.xmlを生成 - 実行する
phpコマンドを組み立て、実行する coverage-pucoディレクトリ配下にカバレッジレポートが生成される
[!WARNING] ※
puco初回実行時に、~/.config/puco.tomlという設定ファイルができます。 この設定ファイル内のキー:CommandToSpecifyBeforePHPCommandにdockerコマンド越しにphpコマンドを実行するよう記載していますが、直接phpコマンドを実行したい場合は、このキーの値を""にしていただくか、この行ごと消してください。
- カバレッジレポートをHTML形式以外でも出力できるようにする
- ヒストリー機能欲しい
- 何度もファイル選択は手間。ただ、ツールで組み立てられたコマンドは表示されるので、それコピペで実行でも代替できるから後でいいかも
- 一旦repeatフラグを実装したから、ほんとに欲しくなってからでいいかも
