Skip to content

PhpUnit 10 - Make exception handling extensible again #5630

@zeleznypa

Description

@zeleznypa

For my extraordinary case (implementation), I really need to extend the method verifyExceptionExpectations which is impossible due to it being private. In PhpUnit 9, it was possible to overwrite the assertThat method to do so, but in Phpunit 10 is this method unfortunately final.

When there is a method runTest protected, it makes sense to allow also overwrite directly called methods.

Or please add an event directly after the catch in runTest

try {
    $testResult = $this->{$this->name}(...array_values($testArguments));
} catch (Throwable $exception) {
    // Here
    if (!$this->shouldExceptionExpectationsBeVerified($exception)) {

Or please encapsulate the test execution into a separate method

try {
    $testResult = $this->executeTest($this->name, $testArguments);
    //$testResult = $this->{$this->name}(...array_values($testArguments));
} catch (Throwable $exception) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementA new idea that should be implemented

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions