Strange output from PHPUnit

后端 未结 1 1999
时光说笑
时光说笑 2021-01-12 20:51

I have installed the PHPUnit via the PEAR, and also I have installed the WordPress Plugin Test (https://github.com/tierra/wordpress-plugin-tests) to test my WordPress Plugin

相关标签:
1条回答
  • 2021-01-12 21:10

    Those are color codes for unix consoles and they are hard coded in the phpunit framework as you can see here: https://github.com/sebastianbergmann/phpunit/blob/master/PHPUnit/TextUI/ResultPrinter.php

    Example: lines 500 to 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;
        }
    

    I believe you can hide the colors setting the attribute colors="false" in your phpunit.xml file:

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

    You can read more here: http://phpunit.de/manual/3.7/en/appendixes.configuration.html

    0 讨论(0)
提交回复
热议问题