5

I have a project where I ran phpunit with code coverage on the ./app folder. This worked fine and the phpunit.xml file had this section.

    <coverage processUncoveredFiles="true">
        <include>
            <directory suffix=".php">./app</directory>
        </include>
    </coverage>

Since then, I changed the structure and made namespaced modules. Now the code coverage does not cover the modules at all. My phpunit.xml section looks like this now.

    <coverage processUncoveredFiles="true">
        <include>
            <directory suffix=".php">./app</directory>
            <directory suffix=".php">./module/module-one/src</directory>
            <directory suffix=".php">./module/module-two/src</directory>
            <directory suffix=".php">./module/module-three/src</directory>
        </include>
    </coverage>

After this change, only the ./app files are shown in the report and there is no indication of any other files. Even the report root is /app. I have tried several configurations e.g. using only ./module as the directory, but nothing has worked.

The phpunit.xml file is being read, because the generation reacts to changes in the file.

How can I include the rest of the files in the report?

PHPunit version is 9.5.13, XDebug version is 3.0.3, and Code Coverage version is 1.0.8

2
  • Have you find the issue ? I have the same problem. Commented Aug 23, 2023 at 17:39
  • Same issue here, found any solution? Commented Nov 23, 2024 at 0:09

1 Answer 1

1
  1. Please check your composer.json that need to autoload each module folders you provided.

  2. Please make sure that your Pcov exensions disabled on the first place. pcov.enabled=0 https://github.com/krakjoe/pcov

Sign up to request clarification or add additional context in comments.

1 Comment

If you're using pcov for coverage, another thing to check is setting pcov.directory appropriately for your situation. By default it'll look for src, lib, or app in the current working directory. For example php -dpcov.enabled=1 -dpcov.directory=. -d pcov.exclude='~vendor~' vendor/bin/phpunit ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.