Closed tklie closed 1 year ago
@tklie thank you for reporting this problem. I believe this is an issue with PHPUnit as the same issue occurs when marking tests as incomplete in an after method even without our package.
I created an issue with them: https://github.com/sebastianbergmann/phpunit/issues/5337
Their response was quick, see https://github.com/sebastianbergmann/phpunit/issues/5337#issuecomment-1513000069
The "after test method" is not, and was never, intended for a use case like that. By the time such methods are called, no decision on the outcome of a test can be made anymore. That this worked for you in the past, with PHPUnit 9, for instance, was accidental.
The markTestIncompleteIfSnapshotsHaveChanged() method in your trait should use the #[PostCondition] attribute instead of #[After] (or the
@postCondition
annotation instead of the@after
annotation if you want/have to use annotations).
Since I was just working on a project using this package, I tried it and confirm changing @postCondition
worked.
As the title says, tests are not correctly marked as
Incomplete
when creating/updating snapshots. Instead PHPUnit displays them asErrors
.PHP 8.2.4 laravel/framework 10.7.1 phpunit/phpunit 10.1.0 spatie/phpunit-snapshot-assertions 5.0.1
Manually calling
$this->markTestIncomplete('Test incomplete')
within a test works perfectly fine. But this packages calls this method from within themarkTestIncompleteIfSnapshotsHaveChanged()
method which is using an@after
annotation. Exceptions thrown during this test lifecycle appear to be treated differently.Testcases
Command
Expected Result
Actual Result