Windows PHPUnit的奇怪输出
我已经通过PEAR安装了PHPUnit,还安装了WordPress插件测试()来测试我正在开发的WordPress插件 问题是,当测试正常运行时,我得到以下输出:Windows PHPUnit的奇怪输出,windows,unit-testing,phpunit,Windows,Unit Testing,Phpunit,我已经通过PEAR安装了PHPUnit,还安装了WordPress插件测试()来测试我正在开发的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. Co
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]
我的系统是Windows7,我运行XAMPP,通过PEAR安装了PHPUnit
所以,我可以以某种方式解决这个问题,因为输出不太清晰,无法读取
这些是unix控制台的颜色代码,它们在phpunit框架中是硬编码的,您可以在这里看到: 示例:第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>
您可以在此处阅读更多内容:看起来颜色代码没有正确转义,这很可能与您的shell有关。您的shell是什么,您使用的终端应用程序是什么?正如我上面所述,这是Windows 7上的CMD控制台,谢谢:)什么类型的shell?您的意思是什么?我通过命令运行PHPUnit测试Windows 7的行您可以在此处找到此报告:-由于您是Windows用户,请参阅可能的重复