PHPUnit showing passed methods that throws Fatal Error Exception

萝らか妹 提交于 2019-12-11 15:44:49

问题


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.

So it seems that PhpUnit cannot handle these exception and it just marks them as passed.

This would work fine

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

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.


回答1:


You can use @runInSeparateProcess annotation.
Please see details.
https://phpunit.readthedocs.io/en/7.3/annotations.html#runinseparateprocess.



来源:https://stackoverflow.com/questions/52554619/phpunit-showing-passed-methods-that-throws-fatal-error-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!