Skip to content

TestCase::onNotSuccessfulTest cannot mark tests as skipped or failed anymore in PHPUnit 10 #5202

@stof

Description

@stof
Q A
PHPUnit version 10.0.7
PHP version 8.1.15
Installation Method Composer

Summary

In PHPUnit 9 and older, it was possible to override TestCase::onNotSuccessfulTest to change the outcome of a test, as this method was called before determining the test status based on the caught exception (and this method could throw a different one that would be used).
In PHPUnit 10, this method is called after determining the test status, which voids any use case I know for that extension point.

Examples of usage of that method:

Current behavior

How to reproduce

  1. Create a TestCase with a test throwing an exception
  2. Override the onNotSuccessfulTest method in that TestCase to call self::markTestSkipped() when that exception happened
  3. Run those tests both with PHPUnit 9 and 10 and compare the difference.

Expected behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions