【发布时间】:2018-07-03 05:10:12
【问题描述】:
每当我从 Eclipse 运行测试文件时,它都会工作并显示结果为:
. 1/1 (100%)
Time: 371 ms, Memory: 8.00MB
OK (1 test, 1 assertion)
但是如果我从 Eclipse Oxygen 运行相同的测试,我会收到错误:
PHP Fatal error: Declaration of PHPUnitLogger::addFailure(Test $test, AssertionFailedError $e, $time): void must be compatible with PHPUnit\Framework\TestListener::addFailure(PHPUnit\Framework\Test $test, PHPUnit\Framework\AssertionFailedError $e, float $time): void in /tmp/phpunit_printer/PHPUnitLogger.php(415) : eval()'d code on line 1
我下载了 phpunit-7.1.phar,并通过使其可执行并将其移动到 /usr/local/bin 来全局安装它,对于 Eclipse,我已在下载目录中下载,但未使其可执行,我将其添加到我的Eclipse 项目作为外部 Phar 但它不工作并给出上述错误。
有人可以帮我解决这个问题吗?
顺便说一下,我是 NetBeanse 用户,但 NetBeans 不支持 PHP7.1,这就是迁移到 Eclipse 的原因。
更新
这是我的测试文件:
<?php
namespace tests\Unit\;
use PHPUnit\Framework\TestCase;
class MyTest extends TestCase
{
public function testSimple() {
$this->assertEquals(1, 1);
}
}
【问题讨论】:
-
你确定 Eclipse 使用的 phpunit 版本与你在命令行中使用的相同吗?
-
我只能确保我用于全局安装的相同 phpunit phar 并在我的 eclipse 项目中添加为外部 phar。所以,这一定是一样的。