【发布时间】:2014-06-22 22:30:29
【问题描述】:
我重构了一些代码,并使用trigger_error() 和E_USER_DEPRECATED 常量引入了弃用警告。
因此我需要修改涉及该功能的测试
public function testMethod()
{
$expected = 'value';
$actual = $this->subject->callDeprecatedMethod();
$this->assertEquals($expected, $actual)
}
这样方法调用不会引发异常(例如,如here 或here 所述):
public function testMethod()
{
$expected = 'value';
$save = PHPUnit_Framework_Error_Deprecated::$enabled;
PHPUnit_Framework_Error_Deprecated::$enabled = false;
$actual = $this->subject->callDeprecatedMethod();
PHPUnit_Framework_Error_Deprecated::$enabled = save;
$this->assertEquals($expected, $actual)
}
这很好用,但是我意识到,在运行所有测试时,测试运行程序突然在一个点上花费了更长的时间,并且在 checking against JSON 和 PHPStorm 中,为此刚刚更改了 testMethod,时间从毫秒上升到0.71 秒。
如何防止这种情况发生?
我需要我的测试快速快速运行:)
【问题讨论】:
标签: php error-handling phpunit