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

Add option for @covers alt annotation for Test Classes #351

Open
jamisonbryant opened this issue Apr 11, 2024 · 5 comments
Open

Add option for @covers alt annotation for Test Classes #351

jamisonbryant opened this issue Apr 11, 2024 · 5 comments

Comments

@jamisonbryant
Copy link

jamisonbryant commented Apr 11, 2024

Right now only @uses is supported, and it's my understanding that the semantics between @covers and @uses are different in PHPUnit. See: https://edorian.github.io/2011-11-04-An-introduction-to-phpunits-covers-annotation/

I don't believe you can have both...which means every time we run 'bin/cake annotate' we have to remove lots of @uses statements from our tests which already have @covers annotations.

Would also need to update the logic to check for either @uses or @covers already on the class, and not add a new unnecessary annotation.

@dereuromark
Copy link
Owner

dereuromark commented Apr 16, 2024

According to the docs it can be both though:
https://docs.phpunit.de/en/9.6/annotations.html#uses

Bear in mind that currently @uses is not used for PHPUnit but for IDE traceability.
@covers should probably be used for PHPUnit exclusively here.
As long as you don't run it in strict coverage mode, it should work fine.

@jamisonbryant
Copy link
Author

I'm not really sure why, but running annotate all on my current codebase only adds the annotation to three Command tests:

/**
 * MyServiceProviderCommand Test
 *
 * @covers \App\Command\Bake\MyServiceProviderCommand       <-- I put this here
 * @uses \App\Command\Bake\MyServiceProviderCommand         <-- the plugin put this here
 */

As a developer, I would rather not have both of those annotations in my header, though they may both be valid.

@Covers should probably be used for PHPUnit exclusively here.

Are you saying the plugin should use @covers only and not @uses when annotating unit tests?

@dereuromark
Copy link
Owner

Uses is the one for IDEs and clickable afaik

@jamisonbryant
Copy link
Author

jamisonbryant commented Apr 29, 2024 via email

@dereuromark
Copy link
Owner

We can add it on top or configure the Covers instead of uses. But uses should probably stay default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants