Reconsider inheriting `#[Group]` from parent test classes
This is a follow-up to #3935, which asked for #[Group] on a parent test class to apply to its subclasses. It was closed. I want to ask to reconsider it for two reasons.
Attributes are now the only metadata mechanism. PHPUnit already treats the test class hierarchy as one unit in other places: hook methods (
#[Before],#[After], etc.) declared in a parent class are honored, andReflection::sourceFilesOf()walksgetParentClass()up toTestCase. Reading#[Group]from parent classes would be consistent with that.The workaround (repeat the attribute on every concrete class, or split tests by directory) does not fit every project. We have an abstract
FunctionalTestCaseand ourtests/directory mirrorssrc/, so unit and functional tests live side by side. A<testsuite>per directory cannot select only functional tests, and repeating#[Group('functional')]on each class is easy to forget.
Today AttributeParser::forClass() reads attributes from the concrete class only, and TestCase::groups() is final, so there is no user-land option.
Source: sebastianbergmann/phpunit