PHPUnit 的奇怪输出 [英] Strange output from PHPUnit

查看:18
本文介绍了PHPUnit 的奇怪输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过 PEAR 安装了 PHPUnit,还安装了 WordPress 插件测试 (https://github.com/tierra/wordpress-plugin-tests) 来测试我正在开发的 WordPress 插件.

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 that is under development.

当测试正常运行时,我得到以下输出的问题:

The issue that while the test run normaly, I am getting the following Output:

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:LocalWebServerdchcmy-wp-installtion.dchwordpress-testwordpresswp-contentpluginsmypluginphpunit.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:LocalWebServerdchcmy-wp-installtion.dchwordpress-testwordpresswp-contentpluginsmypluginTests	est_CDOAjax_tests.php:7

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

我不知道这是否有帮助,但 phpunit.xml 包含以下内容:

I don't know if that helps, but the phpunit.xml contains the following:

<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.

As you can see, the PHPUnit output has some strange characters, like the last line that contains the [0m[2k.

我的系统是 Windows 7,我使用通过 PEAR 安装的 PHPUnit 运行 XAMPP

My system is a Windows 7 and I run XAMPP with PHPUnit installed via the PEAR

那么,我能不能以某种方式解决这个问题,因为输出不是很清楚,无法阅读.

So, can I fix that issue somehow, because the output is not so clear for reading.

亲切的问候

推荐答案

这些是 unix 控制台的颜色代码,它们在 phpunit 框架中被硬编码,如您在此处看到的:https://github.com/sebastianbergmann/phpunit/blob/master/PHPUnit/TextUI/ResultPrinter.php

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

示例:第 500 到 509 行.

Example: lines 500 to 509.

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

        $this->lastTestFailed = TRUE;
    }

我相信您可以在 phpunit.xml 文件中隐藏设置属性 colors="false" 的颜色:

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

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

您可以在此处阅读更多信息:http://phpunit.de/manual/3.7/en/appendixes.configuration.html

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

这篇关于PHPUnit 的奇怪输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆