Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

More generic matching for at covers annotation #4937

Closed
designermonkey opened this issue Mar 23, 2022 · 2 comments
Closed

More generic matching for at covers annotation #4937

designermonkey opened this issue Mar 23, 2022 · 2 comments
Labels
feature/code-coverage Issues related to code coverage (but not php-code-coverage) feature/metadata Issues related to attributes and annotations type/enhancement A new idea that should be implemented

Comments

@designermonkey
Copy link

From my learnings of unit testing, the importance is placed on testing the unit of functionality, not individual classes.

With that in mind, I declare an interface and create a testable implementation of that interface. According to PHPUnit, I am to declare the @covers annotation set to that class, and for every class covered. Good so far.

In testing, implementing, and then refactoring my code, I break my implementation class out into smaller 'private' classes (like in Java) that will never be instantiated outside the scope of the covered class. PHPUnit currently requires that I add another @covers annotation for every class I refactor out.

Would it be simpler to declare wildcard patterns like:

@covers \My\Space\MyClass
@covers \My\Space\MyClass\*

The first is the class implementing the interface, the second is the namespace for those pseudo 'private' classes.


In an ideal world, I would love to be able to declare @covers \My\Space\MyClass and it be treated as a class and/or namespace to cover.

@designermonkey designermonkey added the type/enhancement A new idea that should be implemented label Mar 23, 2022
@sebastianbergmann
Copy link
Owner

No new annotations will be added, no existing annotations will be changed, see #4502 for details. That being said, I am open to the idea of adding metadata support for declaring that a class covers a namespace.

@sebastianbergmann sebastianbergmann added feature/code-coverage Issues related to code coverage (but not php-code-coverage) feature/metadata Issues related to attributes and annotations labels Mar 23, 2022
@sebastianbergmann
Copy link
Owner

I believe this to be addressed by #4463.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/code-coverage Issues related to code coverage (but not php-code-coverage) feature/metadata Issues related to attributes and annotations type/enhancement A new idea that should be implemented
Projects
None yet
Development

No branches or pull requests

2 participants