eliashaeussler/phpunit-attributes
PHPUnit Attributes adds modern PHP 8 attributes to define PHPUnit tests, data providers, groups, dependencies and more in a clean, declarative way. Keep test classes readable and reduce annotation/docblock noise while staying compatible with PHPUnit workflows.
Begin by installing the package via Composer:
composer require --dev eliashaeussler/phpunit-attributes
Once installed, start by using the included attributes—like @Test, @dataProvider, or @group replacements (e.g., Test, DataProvider, Group)—directly in your PHPUnit test classes. These are fully compatible with PHPUnit’s native attribute system and require no additional bootstrapping. Your first step should be to refactor a simple test method that uses a docblock annotation (e.g., @dataProvider) to use the corresponding native attribute. Check the src/ directory for the full list of available attributes and inspect phpunit.xml configuration if needed for extended integration.
Group, Medium, Slow, or custom attributes to categorize tests by environment, runtime, or ownership—e.g., #[Group('integration')]—for targeted execution via CLI (--group=integration).@dataProvider docblocks with #[DataProvider(SomeProvider::class)], keeping the provider class reference directly above the test.Test with descriptive names and Description attributes (#[Description('Verifies ...')]) to clarify purpose without external docs.#[Test, Database, Slow]) in traits for consistent setup across suites.phpunit-attributes on older PHP will yield parse errors.Test or Group—they may conflict with PHPUnit’s built-in or this package’s attributes unless explicitly namespaced. Prefix your custom attributes if needed (e.g., #[App\Attributes\Coverage(…)]).EliasHaeussler\PHPUnitAttributes\AbstractAttribute and register them via phpunit.xml or a custom bootstrap if needed (though most attributes work out-of-the-box).eliashaeussler/phpunit-attributes package typically tracks PHPUnit 9.5+ and 10+, but always check the release notes for compatibility.use EliasHaeussler\PHPUnitAttributes\...) and that PHPUnit’s autoloader loads it. Use phpunit --list-tests to confirm test discovery includes your annotated methods.How can I help you explore Laravel packages today?