Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Deprecate support for #[CoversTrait] and #[UsesTrait] attributes #5958

Closed
sebastianbergmann opened this issue Sep 21, 2024 · 0 comments
Closed
Assignees
Labels
feature/code-coverage Issues related to code coverage (but not php-code-coverage) feature/metadata/attributes type/backward-compatibility Something will be/is intentionally broken
Milestone

Comments

@sebastianbergmann
Copy link
Owner

The #[CoversTrait] and #[UsesTrait] attributes were introduced in PHPUnit 11.2 while/after working on #5798.

Had I been aware at the time that #[CoversClass] and #[UsesClass] also target the traits used by the targeted classes, I would not have implemented the #[CoversTrait] and #[UsesTrait] attributes. As of 17bbefa, this behaviour is now documented in tests.

The #[CoversTrait] and #[UsesTrait] attributes are therefore not needed and will be deprecated in PHPUnit 11.4 and removed in PHPUnit 12.

If you currently use #[CoversClass] or #[UsesClass] to target traits: don't. Testing traits in isolation from their embedding classes is not useful.

If you currently use #[CoversTrait] or #[UsesTrait] to target traits: don't. The traits used by the class(es) you target with #[CoversClass] or #[UsesClass] will be targeted as well.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature/code-coverage Issues related to code coverage (but not php-code-coverage) feature/metadata/attributes type/backward-compatibility Something will be/is intentionally broken
Projects
None yet
Development

No branches or pull requests

1 participant