Ikke
Ikke

Reputation: 101221

PHPUnit codecoverage halts without reporting any error

When executing PHPUnit with codecoverage, the coverage generating just halts without any error, and no report is generated.

The problem is caused by a fatal error in one file, but it's hard to find what the error is without any error showing up.

I have confirmed display_errors is on, and I have set error_reporting to -1 in php.ini

After much testing with excluding files from coverage, I have found the file in error, and also what the error is (class not implementing inherited abstract methods), but this could have gone faster if I had an actual error.

Upvotes: 0

Views: 141

Answers (1)

Ikke
Ikke

Reputation: 101221

The problem was in the PHPUnit config being used.

I had set error reporting like this:

<php>
    <ini name="error_reporting" value="E_ALL & ~E_STRICT" />
</php>

I thought that should work, but it appears that you can only provide constants (E_ALL) or literal values, not expressions like that. This config will set error_reporting to 'E_ALL & ~E_STRICT', instead of the correct numeric value, causing all errors to be muted.

I have solved this by setting error_reporting in the phpunit bootstrap file.

Upvotes: 1

Related Questions