Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Errors in after-last-test methods are not reported #6094

Closed
jocutajar opened this issue Jan 7, 2025 · 3 comments
Closed

Errors in after-last-test methods are not reported #6094

jocutajar opened this issue Jan 7, 2025 · 3 comments
Assignees
Labels
feature/test-runner CLI test runner type/bug Something is broken version/10 Something affects PHPUnit 10 version/11 Something affects PHPUnit 11

Comments

@jocutajar
Copy link

after class exceptions are just swallowed and you need the debugger to understand what is going on

Originally posted by @BafS in 258e4e9

@sebastianbergmann
Copy link
Owner

Thank you for your report.

Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting.

Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue.

@sebastianbergmann sebastianbergmann added the status/waiting-for-feedback Waiting for feedback from original reporter label Jan 8, 2025
@BafS
Copy link

BafS commented Jan 9, 2025

Tested with PHPUnit 11 but it should be the same with v10

in tests/A.php

<?php

class ATest extends \PHPUnit\Framework\TestCase
{
    public static function tearDownAfterClass(): void {
        echo PHP_EOL . 'THIS SHOULD FAIL' . PHP_EOL;
        throw new \Exception('A-FAIL');
    }

    public function testA(): void {
        self::assertTrue(true);
    }
}

Run it:

./vendor/bin/phpunit tests/ATest.php
PHPUnit 11.5.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.14

.                                                                   1 / 1 (100%)
THIS SHOULD FAIL


Time: 00:00.006, Memory: 6.00 MB

OK (1 test, 1 assertion)

It's eaten by the empty catch(), there is no message, no failure.

@sebastianbergmann sebastianbergmann added feature/test-runner CLI test runner version/11 Something affects PHPUnit 11 version/10 Something affects PHPUnit 10 type/bug Something is broken and removed status/waiting-for-feedback Waiting for feedback from original reporter labels Jan 9, 2025
@sebastianbergmann sebastianbergmann changed the title Handle after class exceptions Errors in after-last-test methods are not reported Jan 10, 2025
@sebastianbergmann sebastianbergmann self-assigned this Jan 10, 2025
@BafS
Copy link

BafS commented Jan 12, 2025

Thank you!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature/test-runner CLI test runner type/bug Something is broken version/10 Something affects PHPUnit 10 version/11 Something affects PHPUnit 11
Projects
None yet
Development

No branches or pull requests

3 participants