dar*_*ale 4 php phpunit composer-php
我正在使用我的composer.json文件中定义的 Composer 脚本在我的应用程序中运行单元测试。
我的composer.json:
{
"name": "my company/my_application",
"description": "Description of my application",
"license": "my licence",
"require": {
"php": ">=5.6",
"ext-soap": "*",
"ext-ssh2": "*",
"ext-curl": "*",
"ext-zip": "*",
"ext-pdo_mysql": "*",
"ext-gettext": "*",
"dusank/knapsack": "^9.0"
},
"require-dev": {
"ext-mysqli": "*",
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "2.*"
},
"scripts": {
"test-php": "vendor/bin/phpunit --colors --verbose --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml",
}
}
Run Code Online (Sandbox Code Playgroud)
我的命令是:
vendor/bin/phpunit --colors --verbose --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests/
Run Code Online (Sandbox Code Playgroud)
如果我vendor/bin/phpunit --colors --verbose --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests/在终端内运行,我可以看到彩色输出。但是如果我使用 Composer 运行它,我看不到任何颜色。
使用 composer.json 中定义的 Composer 脚本,如何显示 phpunit 颜色?
要强制PHPUnit来显示颜色在任何情况下,添加=always到--color参数。
和
vendor/bin/phpunit --colors=always --verbose --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests/
Run Code Online (Sandbox Code Playgroud)
在我的composer.json文件中,我可以看到颜色。