sebastianbergmann / phpunit

The PHP Unit Testing framework.
https://phpunit.de/
BSD 3-Clause "New" or "Revised" License
19.71k stars 2.2k forks source link

Optionally (fail|stop) on (notice|deprecation) events #5196

Closed hemberger closed 1 year ago

hemberger commented 1 year ago

In PHPUnit 9, it was possible to get a non-zero exit code from phpunit if any tests encountered a warning, notice, or deprecation (with the proper configuration). This was very helpful for strictly prohibiting all error events.

I appreciate the distinction between test outcomes and test issues in PHPUnit 10, but I find myself missing the option for the process to return a non-zero exit code when there are any issues. This is still possible for warnings with failOnWarning, but it appears that no such option exists for notices or deprecations. Perhaps it would make sense to have boolean options failOnNotice and failOnDeprecation to fill this role? (This would also provide parity with the new displayDetailsOnTestsThatTrigger* options.)

If this functionality already exists, but I just missed it, my apologies! Thanks for all the work on PHPUnit 10. I'm very excited to start using it (especially for the code coverage color/css options, as a colorblind person).

stof commented 1 year ago

While I understand the logic for deprecations, I would still appreciate an option to fail on notices. A library that triggers notices when using it will often be considered bad as many frameworks turn notices into exceptions in dev mode.

VincentLanglet commented 1 year ago

In PHPUnit 9, the option convertDeprecationsToExceptions were failing only on deprecations

trigger_error('User Deprecation', \E_USER_DEPRECATED);

but not on

@trigger_error('User Deprecation', \E_USER_DEPRECATED);

Currently PHPUnit 10 consider both the same way

OK, but some tests have issues!
Tests: 1, Assertions: 4, Deprecations: 1.

So if we just add an option failOnDeprecation we won't get back the same behavior than the one in PHPUnit 9...

sebastianbergmann commented 1 year ago

So if we just add an option failOnDeprecation we won't get back the same behavior than the one in PHPUnit 9.

Please do not mix unrelated topics and post similar comments on different issues.