PHPUnit:致命错误处理 [英] PHPUnit : Fatal error handling

查看:179
本文介绍了PHPUnit:致命错误处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PHPUnit进行单元测试,但是当触发致命错误时,脚本死亡,我没有正确的PHPUnit输出。

I use PHPUnit for unit tests, but when a fatal error is triggered, the script dies and I have no correct PHPUnit output.

我希望PHPUnit输出保持正确格式化,因为它是由Eclipse插件读取的。实际上,致命的错误会停止PHPUnit,而在Eclipse中,该插件不能解释任何东西(因为PHPUnit脚本错误,而不是处理它)。

I'd like that the PHPUnit output stays correctly formated, because it is read by a plugin for Eclipse. Actually the fatal error stops PHPUnit and in Eclipse the plugin can't interpret anything (because the PHPUnit script had an error, instead of handling it).

谢谢

推荐答案

您需要使用PHPUnit的进程隔离功能 - 在新进程中启动每个测试套件。 >

You need to use PHPUnit's process isolation features - start each test suite in a new process.

phpunit --process-isolation ...

这是确保致命错误不会破坏您的phpunit输出的唯一方法。

This is the only way to make sure fatal errors don't break your phpunit output.

进程隔离使您的测试运行时间倍增,因为每个单独测试 ,启动一个新的PHP实例,执行引导等。

Process isolation multiplies your test run time, because for each single test, a new PHP instance is started, the bootstrap is executed etc.

为了修改这种情况,您可以选择在单独的进程( @runTestsInSeparateProcesses )中运行完整的测试用例,或者只选择已知的单个进程有时会致命( @runInSeparateProcess )。

To amend this situation, you may choose to run full test cases in a separate process (@runTestsInSeparateProcesses), or only single ones that are known to fatal out sometimes (@runInSeparateProcess).

这篇关于PHPUnit:致命错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆