-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TestDox printer does not consider that issues can be suppressed by attribute, baseline, source location, or @
operator
#5884
Comments
Consider this example: <?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class ExampleTest extends TestCase
{
public function testSucceeds(): void
{
$this->assertTrue(true);
}
public function testFails(): void
{
$this->assertTrue(false);
}
public function testRisky(): void
{
}
} Running the test shown above with PHPUnit 10 and the
In the example above, the Running the same test with PHPUnit 9 and the
As you can see, PHPUnit 9 had the same TestDox output (it used I am closing this issue now as this works as intended. I have opened sebastianbergmann/phpunit-documentation-english#360 to track improvements to the documentation of TestDox output. |
This is not just a documentation issue. As you can see from the summary, there are no risky tests:
Moreover, there were no tests marked risky in PHPUnit 9. These warning icons suddenly appear in PHPUnit 10 without apparent cause. |
I see this behavior too: Plant Images Resource (App\Tests\Functional\PlantImagesResource) Pricegroup (App\Tests\Functional\Pricegroup) Print Text Label (App\Tests\Functional\PrintTextLabel) User (App\Tests\Functional\User) zettle Service (App\Tests\Service\zettleService) FAILURES! No risky tests, still an exclamation icon on some tests. But it gets worse. Plant Images Resource (App\Tests\Functional\PlantImagesResource) Pricegroup (App\Tests\Functional\Pricegroup) Print Text Label (App\Tests\Functional\PrintTextLabel) User (App\Tests\Functional\User) zettle Service (App\Tests\Service\zettleService) FAILURES! This is run using phpunit 10.5.27 in a Symfony app. |
In case it matters, mine is also a Symfony app. In any case, I think this issue needs to be reopened as it seems clear something is raising a risky event but nothing is forwarding the reason to the end-user, making it entirely opaque why these tests are being so marked. More importantly, only the testdox printer is sensitive to these events; the summary does NOT report any tests as being risky. |
I had the same issue: Testdox shows warnings, but I had no warnings in the summary. I dig a bit the issue and it appears that I used the You can easily reproduce the issue with this test: class WarningsTest extends PHPUnit\Framework\TestCase
{
public function testWarning(): void
{
$folder = sys_get_temp_dir() . '/documents';
if (is_dir($folder)) {
// Just make sure to start with a clean state
rmdir($folder);
}
mkdir($folder);
// This will generate a PHP warning which will be silenced.
// The default output shows nothing, while Testdox shows a warning but
// cannot tell what it is. Removing the `@` shows the warning in both output.
@mkdir($folder);
$this->assertTrue(is_dir($folder));
}
} |
I detected these warnings by running the tests of this specific file. It appears that silenced warnings are detected by the Testdox output, but not by the default output. The best would be to never use `@` anyway. Reference: sebastianbergmann/phpunit#5884
Came here to report the same as I noticed this on two different repos today. @sebastianbergmann Can this issue please be re-opened ?
I can confirm this. IF the error silencing operator is being used (either in the code under test or the test itself) AND a deprecation/notice/warning is being raised (and silenced), the warning icon appears. However, if the test is then marked with I've also found another situation which triggers the appearance of the warning icon, where IMO it is inappropriate: I've set up a relatively simple reproduction scenario, which can be checked-out here: https://github.com/jrfnl/bug-report-reproduction-scenarios/tree/phpunit/5884-demo-code The different output of the reproduction scenarios on PHPUnit 9/10/11 can also be seen in the GH Actions workflow output: https://github.com/jrfnl/bug-report-reproduction-scenarios/actions/runs/10672517439 [Edit]: What I find most confusing about these warning symbols, is - as @Bilge has also pointed out - that there is seemingly no explanation for the appearance of the symbols (in the test output) and you have to go digging to find this issue to figure out why they appear. |
Thank you, Juliette, for the reproducing example. I now (finally) understand what the issue is. I am working on a fix for PHPUnit 10.5 and PHPUnit 11.3 right now. |
@
operator
Thank you so much for reconsidering and for working on the fix @sebastianbergmann! |
Summary
Testdox prints seemingly-random warning icons (⚠) next to some tests when a test suite passes with 100% success. I could not find the documented meaning behind this anywhere, and searching the code for that emoji did not yield any results, so I'm assuming it's either a bug or undocumented feature, but either way it is very confusing and was not present in PHPUnit 9.
Current behavior
Testdox will print warnings next to some tests for no discernable reason whatsoever.
How to reproduce
Run some tests?
Expected behavior
If the summary shows 100% OK, I would not expect to see warning icons in the summary output. If there are warnings, I expect to see details of what those warnings are somewhere.
The text was updated successfully, but these errors were encountered: