Inherit class-level `#[Group]`, `#[Ticket]`, `#[Small]`, `#[Medium]`, and `#[Large]` from parent classes of test classes
As of PHPUnit 14, a class-level #[Group], #[Ticket], #[Small], #[Medium], or #[Large] attribute on a parent class of a test class applies to the tests of that test class. This was deprecated in PHPUnit 13.4 (see #6999).
#[Ticket], #[Small], #[Medium], and #[Large] are aliases for #[Group], so all five attributes are inherited to keep them consistent.
#[Group('functional')]
abstract class FunctionalTestCase extends TestCase
{
}
final class InvoiceTest extends FunctionalTestCase
{
public function testSomething(): void
{
// ...
}
}InvoiceTest::testSomething() is in the functional group and is selected by --group functional.
The groups of a test are the union of the groups declared on the test method, on the test class, and on all parent classes of the test class up to PHPUnit\Framework\TestCase. A test that inherits a group is no longer in the implicit default group.
A test has only one size, so the nearest declaration of #[Small], #[Medium], or #[Large] wins: a size declared on the test class overrides a size declared on a parent class, and a size declared on a parent class overrides a size declared on its own parent class.
This is a change in behaviour that affects which tests are selected by --group, --exclude-group, and the <groups> element of the XML configuration file. Tests that were run before can be excluded after upgrading to PHPUnit 14. Inherited sizes can also change the time limit of a test (when time limits are enforced) and its position when tests are ordered by size.
The groups a test inherits are also reported by --list-groups, --list-tests-xml, the Open Test Reporting XML logger, and the metadata in test events.
Source: sebastianbergmann/phpunit