PHPunit - 错误

2022-01-25 00:00:00 php phpunit

当发生 PHPunit 框架不希望发生的错误时,测试停止,PHP 抛出错误,但 PHPunit 不会记录这是一个错误.如何确保 PHPunit 将其记录为错误.

When an error that the PHPunit framework does not expect to occur happens, the testing stops, and PHP throws the error, but PHPunit does not record that it was an error. How do I make sure PHPunit records it as an error.

推荐答案

免责声明,我是 PHPUnit 的新手,我也想弄清楚发生错误时会发生什么".

来自 PHPUnit 的文档:

当测试代码包含 PHP 语法错误时,TextUI 测试运行器可能会退出而不打印错误信息.标准测试套件加载器可以选择检查测试套件源文件是否存在 PHP 语法错误,但不能检查测试套件源文件包含的源文件.

When the tested code contains PHP syntax errors, the TextUI test runner might exit without printing error information. The standard test suite loader can optionally check the test suite sourcefile for PHP syntax errors, but not sourcefiles included by the test suite sourcefile.

还有选项:

--syntax-check           Try to check source files for syntax errors.

相关文章