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

CommentFileSizeAuthor
#1 2404489_1.patch586 bytesMile23
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mile23’s picture

Status: Active » Needs review
FileSize
586 bytes

As always, you can check this by generating a coverage report. Note that this could take some time.

$ cd core/
$ ./vendor/bin/phpunit --coverage-text
daffie’s picture

Status: Needs review » Reviewed & tested by the community

I 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 :(

dawehner’s picture

BTW: There are no test-assertion in the test-class for anything :(

So, 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.

Mile23’s picture

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.

It'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.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed c9b8b83 and pushed to 8.0.x. Thanks!

  • alexpott committed c9b8b83 on 8.0.x
    Issue #2404489 by Mile23: CacheTagsInvalidatorTest::testInvalidateTags...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.