PHPUnit 显示传递的方法抛出致命错误异常
PHPUnit showing passed methods that throws Fatal Error Exception
我在 Netbeans 上使用 PHPUnit 时遇到问题,当方法抛出一些异常(如致命错误或其他)时,很少有方法显示为已通过。
所以 PhpUnit 似乎无法处理这些异常,它只是将它们标记为已通过。
这会很好
$this->assertEquals(true, 1 == 2);
无法断言 false 与预期的 true 匹配。
但是如果我添加一些抛出异常的代码,那么它只是将其标记为已通过作为示例:
public function testEquals() {
thisMethodDoesNotExists(5);
}
它将此标记为已通过,因为它不应该出现致命错误。
您可以使用 @runInSeparateProcess
注释。
请查看详情。
https://phpunit.readthedocs.io/en/7.3/annotations.html#runinseparateprocess.
我在 Netbeans 上使用 PHPUnit 时遇到问题,当方法抛出一些异常(如致命错误或其他)时,很少有方法显示为已通过。
所以 PhpUnit 似乎无法处理这些异常,它只是将它们标记为已通过。
这会很好
$this->assertEquals(true, 1 == 2);
无法断言 false 与预期的 true 匹配。
但是如果我添加一些抛出异常的代码,那么它只是将其标记为已通过作为示例:
public function testEquals() {
thisMethodDoesNotExists(5);
}
它将此标记为已通过,因为它不应该出现致命错误。
您可以使用 @runInSeparateProcess
注释。
请查看详情。
https://phpunit.readthedocs.io/en/7.3/annotations.html#runinseparateprocess.