PHPUnit显示传递的方法引发致命错误异常 [英] PHPUnit showing passed methods that throws Fatal Error Exception
问题描述
我在Netbeans上遇到PHPUnit的问题,当方法抛出诸如致命错误之类的异常时,很少有方法显示通过.
I am having problem with PHPUnit on Netbeans where few methods are showing as passed when the method throws some exception like Fatal error or something.
因此,看来PhpUnit无法处理这些异常,而只是将它们标记为已通过.
So it seems that PhpUnit cannot handle these exception and it just marks them as passed.
这会很好
$this->assertEquals(true, 1 == 2);
未能断言false匹配预期为true.
Failed asserting that false matches expected true.
但是,如果我添加了引发某些异常的代码,那么它只是将其标记为已通过:
but if I add some code that throws some exception then it just marks it as passed as an example:
public function testEquals() {
thisMethodDoesNotExists(5);
}
将其标记为已通过,不应出现致命错误.
It marks this as passed where it should not cz there is a fatal error.
推荐答案
您可以使用@runInSeparateProcess
注释.
请查看详细信息.
https://phpunit.readthedocs.io/zh/7.3/annotations.html# runinseparateprocess .
You can use @runInSeparateProcess
annotation.
Please see details.
https://phpunit.readthedocs.io/en/7.3/annotations.html#runinseparateprocess.
这篇关于PHPUnit显示传递的方法引发致命错误异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!