Change History (6)

While I am definitely a proponent of thorough unit tests, I am -1 on adding annotations for code coverage, and in general I think the @covers annotation is not a good idea. I will try to explain why.

Someone will have to update every single test to indicate which functions are covered. This will be a manual process requiring an enormous amount of effort, not only now, but in perpetuity. I can't speak for everyone but I personally don't want to do this in my patches.

It is virtually guaranteed that tests will not be consistently updated with @covers annotations in the future. (It's hard enough to ensure that tests are written in the first place.) Even if we do a huge effort now to add them, the coverage reports will become essentially useless in the future due to attrition.

Per-function coverage is not a very useful thing to report on. Consider: @covers wp_update_post. This is a very long function with a lot of complicated logic. Line-by-line coverage reporting is far more useful.

I don't want to read lots of lines of @covers and other annotations in the test code. I think we already have too many of these annotations and they are just visual noise, because the information about which functions are called is already present in the test code itself.

I would be far more interested in an effort to provide automated code coverage reports on a line-by-line basis, perhaps with results split by WordPress component or something like that. I do think this would be really valuable, and once it's set up, there's far less ongoing maintenance required.

Hey, @jnylen0 what version of phpunit are you using?
I got the same bug in version 5.1.3. Downloading and using the phpunit 5.7 version .phar worked for me. The report was generated successfully and it looks like this:
​https://ibb.co/e4UNAk