语境
我正在使用我的 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",
}
}
我的命令是:
vendor/bin/phpunit --colors --verbose --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests/
问题
如果我运行
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/
在我的
composer.json
文件,我可以看到颜色。
关于php - 使用 composer.json 中定义的 Composer 脚本,如何显示 phpunit 颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44550254/