6

PEAR 経由で PHPUnit をインストールしました。また、WordPress プラグイン テスト ( https://github.com/tierra/wordpress-plugin-tests ) をインストールして、開発中の WordPress プラグインをテストしました。

テストが正常に実行されている間に、次の出力が得られるという問題:

Running as single site... To run multisite, use -c multisite.xml
Not running ajax tests... To execute these, use --group ajax.
PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from E:\LocalWebServer\dch\c\my-wp-installtion.dch\wordpress-test\wordpress\wp-content\plugins\myplugin\phpunit.xml

[41;37mF[0m.[36;1mS[0m

Time : 1 second, Memory: 30.50Mb

There was 1 failure:

1) CDOAjax_Tests::test_tests
Failed asserting that false is true.

E:\LocalWebServer\dch\c\my-wp-installtion.dch\wordpress-test\wordpress\wp-content\plugins\myplugin\Tests\test_CDOAjax_tests.php:7

[37;41m[2KFAILURES!
[0m[37;41m[2KTests: 3, Assertions: 2, Failures: 1, Skipped: 1.
[0m[2K

それが役立つかどうかはわかりませんが、phpunit.xml には次のものが含まれています。

<phpunit
bootstrap="bootstrap_tests.php"
backupGlobals="false"
colors="true"
>
    <testsuites>
        <!-- Default test suite to run all tests -->
        <testsuite name="cabdriver">
            <directory prefix="test_" suffix=".php">tests</directory>
        </testsuite>
    </testsuites>
</phpunit>

ご覧のとおり、PHPUnit の出力には、[0m[2k.

私のシステムは Windows 7 で、PEAR 経由でインストールされた PHPUnit で XAMPP を実行しています。

出力が読みにくいので、どうにかしてその問題を修正できますか。

敬具

4

1 に答える 1

13

これらは UNIX コンソールのカラー コードであり、ここで確認できるように phpunit フレームワークでハード コードされています: https://github.com/sebastianbergmann/phpunit/blob/master/PHPUnit/TextUI/ResultPrinter.php

例: 500 行目から 509 行目。

public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
    {
        if ($this->colors) {
            $this->writeProgress("\x1b[31;1mE\x1b[0m");
        } else {
            $this->writeProgress('E');
        }

        $this->lastTestFailed = TRUE;
    }

phpunit.xml ファイルで属性 colors="false" を設定して色を非表示にできると思います:

<phpunit colors="false">
  <!-- ... -->
</phpunit>

ここで詳細を読むことができます: http://phpunit.de/manual/3.7/en/appendixes.configuration.html

于 2013-06-23T19:36:22.077 に答える