Windows環境でGrowlによるStagehand_TestRunnerのテスト結果通知
なんかMacユーザの皆さんがGrowl Growlって言ってるけど…どーせWindowsじゃ使えないんでしょ、って勝手にやさぐれてたら、実はWindows用のクローンがあったんです。(今更気付きました…)
そろそろ、エディタの裏で動いてるStagehand_TestRunnerのAutotestをチラ見するのに疲れてきたところなので(?)、早速Growlによるテスト結果通知を試してみました。
まずは、Growl for Windowsをダウンロードして、インストール。
http://www.growlforwindows.com/gfw/
次に、PEAR Net_Growlをインストール。
[追記]
Stagehand\TestRunner\Notification\Notifierのソース見て疑問に思い、別の環境で試してみたところ、PEAR Net_Growl入れなくても大丈夫なようです。(多分V2.18以降から)
Twitterで@itemanさんからも、その旨コメントいただきました。
Growlへの通知機能については、V2のユーザーガイドの記述が詳しいです。
http://piece-framework.com/projects/stagehand-testrunner/wiki/Stagehand_TestRunner_ユーザーガイド_2_18_0#テスト結果の通知
通知に使用されるコマンドは環境によって異なり、Windows + Growl for Windowsの場合は、growlnotifyコマンドへのパスを通す必要があるようです。
Growl for Windowsのインストールディレクトリ(自分の場合 C:\Applications\Growl)をシステム環境変数Pathに設定しました。
それから上記ユーザーガイド記載の -n オプションを試したところ…。
$ testrunner phpunit -p bootstrap.php -Rn [RuntimeException] The "-n" option does not exist.
そんなオプションねえよ!って怒られました。
testrunner phpunit --help で確認したところ、V3のPHPUnitでは以下のオプションが有効とのこと。
Options: --preload-script (-p) The PHP script to be loaded before running a command --config (-c) The YAML-based configuration file for Stagehand_TestRunner --recursive (-R) Recursively runs tests in the specified directories. --autotest (-a) Monitors for changes in the specified directories and run tests when changes are detected. --watch-dir (-w) The directory to be monitored for changes (default: The directories specified by the arguments) (multiple values allowed) --notify (-m) Notifies test results by using the growlnotify command in Mac OS X and Windows or the notify-send command in Linux. --detailed-progress (-d) Prints detailed progress report. --stop-on-failure (-s) Stops the test run when the first failure or error is raised. --log-junit Logs test results into the specified file in the JUnit XML format. --log-junit-realtime Logs test results in real-time into the specified file in the JUnit XML format. --test-file-pattern The regular expression pattern for test files (default: Test(?:Case)?\.php$) --test-method The test method to be run (multiple values allowed) --test-class The test class to be run (multiple values allowed) --phpunit-config The PHPUnit XML configuration file
どうも、テスト結果の通知オプション引数は、Stagehand_TestRunnerのバージョンによって g→n→m と変わったみたいです。
というわけで、mオプションで実行します。
$ testrunner phpunit -p bootstrap.php -Rm
おまけ
通知時に表示されるアイコン画像は、Stagehand/TestRunner/Notification/ ディレクトリにある、failed.png, passed.png, stopped.png が利用されています。
画像を変更したい場合は、これを上書きするか、Stagehand/TestRunner/Notification/Notifier.php 冒頭の以下を書き換えるといいみたいです。
Notifier::$ICON_PASSED = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'passed.png'; Notifier::$ICON_FAILED = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'failed.png'; Notifier::$ICON_STOPPED = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'stopped.png
アイコン画像を変えると開発効率UP!という方は、好きなものに変えてみるといいんじゃないでしょうか。