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

How to cover multiple directories? #741

Closed
HenkPoley opened this issue May 7, 2020 · 4 comments
Closed

How to cover multiple directories? #741

HenkPoley opened this issue May 7, 2020 · 4 comments

Comments

@HenkPoley
Copy link

HenkPoley commented May 7, 2020

Q A
php-code-coverage version 8.0.1
PHP version 7.3.17 (and 7.4.5, but same problem)
Driver pcov
Installation Method Composer
Usage Method PHPUnit
PHPUnit version (if used) 9.1.4

I'd like to have code coverage in PhpStorm, on a Laravel 6.x project, on multiple directories.

This is sort of a combination of these closed tickets that seems to have been closed unsatisfactory:

It shows there are 2 boolean toggles that are supposed to influence what is included in the report. addUncoveredFilesFromWhitelist (default: true) and processUncoveredFilesFromWhitelist (default: false). As an example:

        <whitelist
                addUncoveredFilesFromWhitelist="true"
                processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
            <directory suffix=".php">./BrandName</directory>
        </whitelist>

I have toggle them in all the 4 possible states. And ./BrandName/ is never included. I can literally put a dump("hello"); in one of the "0% covered" functions in that directory, and phpunit will keep greeting me over and over. Inside PhpStorm it's shown as 0% covered.

There is a slightly open-ended / vague remark on one ticket:

because you likely include files that not only contain class/interface/trait declarations

I've tried coding the whole directory structure inside ./BrandName directory in phpunit.xml, so I can individually toggle them on or off (maybe all of them disappear if 1 has a problem). But it didn't do anything. So either all of these directories contain "not class/interface/trait declarations", or something else is happening.

I've also tried just <directory suffix=".php">./</directory> and then <exclude> a whole bunch of things. It seems to increase the 'boot time' of phpunit a lot, and it still shows the coverage of the extra directory as 0%, and ./app as some coverage, it additionally also notes the routes that I'm using as 0% covered.

How do I debug this?

Is it in, pcov, phpunit, this package, phpstorm, anything else. Where/how do I start?

@sebastianbergmann
Copy link
Owner

This is not a discussion or support forum, sorry.

@HenkPoley
Copy link
Author

Is there a discussion or support forum for phpunit ?

@HenkPoley
Copy link
Author

As you may or may not be interested in: The issue is in the interfacing between php-code-coverage and pcov. They both have their own disagreeing opinion on directory filtering.

@HenkPoley
Copy link
Author

HenkPoley commented Mar 17, 2021

It would be nice if PhpUnit warned that none of the set up directories are covered by the installed/configured pcov.

Just ran https://github.com/infection/infection for 30 minutes, for nothing. Had to remember I opened this ticket and reconfigure /etc/php/8.0/mods-available/pcov.ini with pcov.directory=..

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

No branches or pull requests

2 participants