Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
I'm trying to generate a PHPUnit coverage report, but I can't.
That's because I see this:
Trying to @cover or @use not existing method "\Drupal\Core\Cache\CacheTagsInvalidator::getBins".
Proposed resolution
Fix the @covers
annotation.
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#1 | 2404489_1.patch | 586 bytes | Mile23 |
Comments
Comment #1
Mile23As always, you can check this by generating a coverage report. Note that this could take some time.
Comment #2
daffie CreditAttribution: daffie commentedI agree with you that "@covers ::getBins" is wrong. But what is wrong is not completely clear to me. Did they mean "@covers ::getInvalidatorCacheBins"? The problem is that I cannot find any test coverage for the function getInvalidatorCacheBins(). So removing the line with "@covers ::getBins" is the right thing to do.
BTW: There are no test-assertion in the test-class for anything :(
Comment #3
dawehnerSo, it has all kind of checks via mocks, I don't consider this as a problem.
Is it just me that I hate having to maintain @covers annotations? It couples your test a lot to your internal structure of the code.
Comment #4
Mile23It's what happens when you allow multiple
@covers
per test method. If you make a proper unit test, you're *only* covering *one* method. That way it's completely clear what has happened, and if you remove the method being tested, you're likely to remove the test method as well.Also, the fact that we use
@covers
as documentation means that we should always have the testbot generate a report, or at least check coverage in some way, so that we know it's correct.Comment #5
alexpottCommitted c9b8b83 and pushed to 8.0.x. Thanks!