
このチュートリアルでは、「コマンドラインシリーズ」として、「コマンドラインでユニットテストを実行する方法」について説明します。ご存知のように、Magento 2 では bin/magento に多くのコマンドが追加されました。これを理解するのは難しいかもしれませんが、「コマンドラインでユニットテストを実行する方法」について詳しく説明します。
コマンドラインでユニットテストを実行する方法
Magento管理画面のルートフォルダに移動し、使用状況を表示します。
php bin/magento dev:tests:run --help
Usage:
dev:tests:run [options] [--] [<type>]
Arguments:
type Type of test to run. Available types: all, unit, integration, integration-all, static, static-a
ll, integrity, legacy, default [default: "default"]
Options:
-c, --arguments=ARGUMENTS Additional arguments for PHPUnit. Example: "-c'--filter=MyTest'" (no spaces) [default: ""]
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
Runs tests
ユニットテストを実行するための構文
php bin/magento dev:tests:run [options]
簡単な実行テスト
php bin/magento dev:tests:run
アウトプット
ERRORS!
Tests: 4163, Assertions: 14590, Errors: 6, Failures: 29, Warnings: 1, Skipped: 173, Incomplete: 1.
----------------------------------------------------------------------
FAILED - 4 of 5:
- dev/tests/unit> /usr/bin/php7.0 ./vendor/phpunit/phpunit/phpunit
- dev/tests/static/framework/tests/unit> /usr/bin/php7.0 ./vendor/phpunit/phpunit/phpunit
- dev/tests/integration> /usr/bin/php7.0 ./vendor/phpunit/phpunit/phpunit
- dev/tests/static> /usr/bin/php7.0 ./vendor/phpunit/phpunit/phpunit