-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
All the new Depends-Attributes only support methods, not classes, which mostly makes sense to me, yet I think it would make sense to be able to target a class for the attribute #[DependsOnClass]
.
The main advantage I see is that PHPUnit could then skip that whole class if any assertion in the depended-on class failed, speeding up the execution of tests and making the failure output more succinct, as only the early failure is shown instead of possibly many additional failures based on the failed dependency. As far as I understand it, the same could be achieved by adding #[DependsOnClass]
on all class methods, but if all test methods rely on the other class, it would be clearer to just have one #[DependsOnClass]
at the top of the class.
As far as I have tested, After more tests, this turned out to be wrong - maybe @depends Classname::class
does work on a class - all tests in the class are skipped in that case, so being able to target classes with #[DependsOnClass]
would be in line with how the equivalent annotation in PHPUnit 9.x worked.@depends
is not supported on classes and I just assumed it was, so this would be purely a new feature.
#[DependsExternal]
might be an additional candidate to be able to target a class with.