collision
collision copied to clipboard
Empty test class doesn't show warning, but breaks CI by passing on non-zero STDERR from PHPUnit
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.
This also affects downstream test packages like Dusk.
https://github.com/laravel/dusk/issues/1063
This also affects the --coverage
option. No coverage output is generated with empty test classes present.
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!
Bump 👀