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

Allow multiple directories for code coverage #3322

Closed
jaesung2061 opened this issue Oct 3, 2018 · 1 comment
Closed

Allow multiple directories for code coverage #3322

jaesung2061 opened this issue Oct 3, 2018 · 1 comment

Comments

@jaesung2061
Copy link

Q A
PHPUnit version 7.3.5
PHP version 7.2.9
Installation Method Composer

I have two directories that I need to check code coverage for. However, there doesn't seem to be a way to include both directories. Attempting to do so causes some kind of auto-loading error.

Example config:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">
    <testsuites>
        <testsuite name="Unit">
            <directory suffix="Test.php">./tests/Unit</directory>
        </testsuite>

        <testsuite name="Feature">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>

        <testsuite name="Modules">
            <directory suffix="Test.php">./modules</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
            <directory suffix=".php">./modules</directory>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-html" target="./tests/report" lowUpperBound="35"
             highLowerBound="70"/>
    </logging>
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="BCRYPT_ROUNDS" value="4"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_CONNECTION" value="sync"/>
        <env name="MAIL_DRIVER" value="array"/>
    </php>
</phpunit>

Notice the two directories ./app and ./modules. The ./modules line is causing errors.

@sebastianbergmann
Copy link
Owner

Whitelisting multiple directories for code coverage works just fine. Do note, though, that all whitelisted files will be included because you set processUncoveredFilesFromWhitelist="true". This is likely the cause for the problem you are experiencing (because you likely include files that not only contain class/interface/trait declarations).

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