PHPUnit显示传递的方法引发致命错误异常

时间:2018-09-28 11:43:07

标签: php unit-testing zend-framework phpunit

我在Netbeans上遇到PHPUnit的问题,当方法抛出诸如致命错误之类的异常时,很少有方法显示通过。

因此看来PhpUnit无法处理这些异常,而只是将其标记为已通过。

这会很好

$this->assertEquals(true, 1 == 2);

未能断言false匹配预期为true。

但是,如果我添加了引发一些异常的代码,那么它只是将其标记为通过示例:

 public function testEquals() {
     thisMethodDoesNotExists(5);
 }

将其标记为已通过,不应出现致命错误。

1 个答案:

答案 0 :(得分:0)

您可以使用@runInSeparateProcess注释。
请查看详细信息。
https://phpunit.readthedocs.io/en/7.3/annotations.html#runinseparateprocess