collision icon indicating copy to clipboard operation
collision copied to clipboard

Empty test class doesn't show warning, but breaks CI by passing on non-zero STDERR from PHPUnit

Open selfsimilar opened this issue 1 year ago • 4 comments

If there are no tests in a test class file, PHPUnit raises a warning (Event\Facade::emitter()->testRunnerTriggeredWarning() - 'no tests found in class') and will pass on a non-zero value to STDERR. Collision will not display this warning, but does pass on the STDERR value, which led to some confusion when it appeared that all tests were passing, but our CI pipeline was stopping at the test step in failure. However, narrowing it down to this issue took a while as at first I thought it was a bug in the CI runner.

You can recreate this with a default Laravel install:

composer create-project laravel/laravel empty-class
cd empty-class
php artisan test
# All tests pass
echo $?
# STDERR is 0
cat <(echo "<?php\nnamespace Tests\\\\Unit;\nuse PHPUnit\Framework\TestCase;\n\nclass EmptyClassTest extends TestCase{}") > tests/Unit/EmptyClassTest.php
php artisan test
# All tests pass
echo $?
# STDERR is 1
vendor/bin/phpunit
# Warnings!

It's not clear to me if this is limited to this one 'empty class' issue, or if all testRunnerTriggeredWarning events are ignored.

selfsimilar avatar Nov 08 '23 22:11 selfsimilar

This also affects downstream test packages like Dusk.

https://github.com/laravel/dusk/issues/1063

selfsimilar avatar Nov 08 '23 23:11 selfsimilar

This also affects the --coverage option. No coverage output is generated with empty test classes present.

RCady avatar Nov 10 '23 22:11 RCady

Hi there, Just wanted to follow up on this. I've also encountered the same issue.

Do we have any updates on the plans for a fix? Additionally, I'm curious about the status of merging/releasing #294. Could someone also explain why this warning was initially hidden/suppresed? Thanks!

abobija avatar Nov 23 '23 17:11 abobija

Bump 👀

abobija avatar Dec 13 '23 07:12 abobija