【问题标题】:Using Composer scripts defined in composer.json, how to display phpunit colors?使用 composer.json 中定义的 Composer 脚本,如何显示 phpunit 颜色?
【发布时间】:2017-11-16 22:18:23
【问题描述】:

上下文

我正在使用在我的 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颜色?

【问题讨论】:

    标签: php phpunit composer-php


    【解决方案1】:

    要强制 phpunit 在任何情况下显示颜色,请将=always 添加到--color 参数中。

    vendor/bin/phpunit --colors=always --verbose --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests/
    

    在我的composer.json 文件中,我可以看到颜色。

    【讨论】:

      猜你喜欢
      • 2015-05-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-07
      • 2021-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-01
      相关资源
      最近更新 更多