-
Notifications
You must be signed in to change notification settings - Fork 34
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
query: re code coverage support #13
Comments
Are you referring to methods in test case classes? |
pretty much- it's quite common that I'll see data providers & test cases pop up, although it'll also crop up for fixtures & utility classes that're implemented specifically for testing. I'm specifically suggesting using coverage because a test method can be skipped if the data provider ends up being empty & if that test method has any dependants with otherwise correct data providers then those would still need to be set as |
Yep, that was my idea (as well as automatically suppressing |
compare edit: comparing to filemod time of baseline is a terrible idea. |
Well, that looks feasible. But then, it sounds pretty generic, so why limit it to tests only? Could be a plugin of its own. |
separate baseline & config files for the environment that runs phpunit ? |
it depends on if you view this plugin as "stubs out phpunit only" or "makes psalm work nicely with phpunit". |
i.e. "psalm thinks this method isn't called but psalm/plugin-phpunit knows better" |
ah, I get what you mean now- it's more than just phpunit generates coverage files :P |
Not just that. It may be used to clean up some false-positives from the system-under-test code as well. In fact, it may actually be only useful to do that, as test code is likely to be excluded from code coverage (with |
I'm insufficiently familiar with how code coverage works to create such a plugin from scratch :s |
Implemented that in #14 |
@SignpostMarv can you provide isolated, short and concise test showing false-positive |
@weirdan smallest testcase: https://github.com/SignpostMarv/psalm-phpunit-psalm-plugin fails with
|
- Invalid providers (should be iterable with array elements) - Providers returning fewer arguments then test requires - Providers returning datasets that are incompatible with test signatures refs psalm#13
- Don't report TestCase descendants as unused - Don't report test methods as unused - Don't report providers referenced by test methods as unused Refs psalm#13 /cc @SignpostMarv
@weirdan the fork takes care of the simple test case- i'm just working over the daft-object fork & master branch to identify how many of these errors are resolved but it's looking good thus far :) |
|
practical example of code that could use coverage support regarding "unused methods": https://github.com/SignpostMarv/Daft-Schema.org The manually created test cases were getting cumbersome to write, so I had a generator generate test cases for me. The coverage shows that all the setters & getters are being called, but this plugin can't flag the methods up as used because very few of them are manually invoked. Not sure what the xpath would be to scan a clover file, but the css-equiv would be |
I still think this would be better done as a separate plugin. You would need to hook into, say, AfterCodebasePopulated, read the coverage xml file and then mark methods as used with methodExists() call. |
Is it feasible for this plugin to parse phpunit coverage files to prevent
PossiblyUnusedMethod
when callingpsalm --find-dead-code
from being flagged up if the method is present as being covered in the coverage file?The text was updated successfully, but these errors were encountered: