PHP 開発ツールでテスト: 簡単CI testrunner

# testrunnerを用意する

とりあえず、最小限のものだけ composer でインストール。

“require-dev”: {
“phpunit/phpunit”: “4.*”,
“piece/stagehand-testrunner”: “4.1.0”

global に testrunner をインストールできないものか試行錯誤したけど、
結局断念して、プロジェクトのフォルダに composer.json を作った。

なので、ここでは testrunner に最小限必要な phpunit だけを指定している。

$ composer.phar update

# testrunnerの実行

インストールしたら、あとは testrunner の実行。

$ ./vendor/bin/testrunner compile -p ./vendor/autoload.php
$ ./vendor/bin/testrunner phpunit -p ./vendor/autoload.php -a tests



$ ./vendor/bin/testrunner phpunit -p ./vendor/autoload.php -a tests -w src


$ ./vendor/bin/testrunner phpunit –help
phpunit [options] [–] []…

test_directory_or_file The directory or file that contains tests to be run (default: The working directory at testrunner startup)

-p, –preload-script=PRELOAD-SCRIPT The PHP script to be loaded before running a command
-c, –config=CONFIG The YAML-based configuration file for Stagehand_TestRunner
-R, –recursive Recursively runs tests in the specified directories.
-a, –autotest Monitors for changes in the specified directories and run tests when changes are detected.
-w, –watch-dir=WATCH-DIR The directory to be monitored for changes (default: The directories specified by the arguments) (multiple values allowed)
-m, –notify Notifies test results by using the growlnotify command in Mac OS X and Windows or the notify-send command in Linux.
-d, –detailed-progress Prints detailed progress report.
-s, –stop-on-failure Stops the test run when the first failure or error is raised.
–log-junit=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=TEST-FILE-PATTERN The regular expression pattern for test files (default: Test(?:Case)?\.php$)
–test-method=TEST-METHOD The test method to be run (multiple values allowed)
–test-class=TEST-CLASS The test class to be run (multiple values allowed)
–phpunit-config=PHPUNIT-CONFIG The PHPUnit XML configuration file
-h, –help Prints help and exit.
-V, –version Prints version information and exit.
–ansi Enables ANSI output.
–no-ansi Disables ANSI output.

The phpunit command runs tests with PHPUnit:

testrunner phpunit …



メールアドレスが公開されることはありません。 * が付いている欄は必須項目です