views:

51

answers:

3

Hi all,

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

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).

Thanks

A: 

try that: http://php.net/manual/en/function.set-error-handler.php

it should give you what you need. write your own error handler function. the only thing you cant catch when are errors during interpretation of your code.

ITroubs
No. The error handler doesn't handle fatal errors.
Matthieu
A: 

set_error_handler() won't help you there. You can catch fatal errors using register_shutdown_function()

stillstanding
As said, I'd like to have a PHPUnit error (I want the phpunit output not to be messed up). I've extended the description of the question.
Matthieu
+2  A: 

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

phpunit --process-isolation ...

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

cweiske