Drupal Test

Code Coverage Reports

  1. Add something like the following to the runner's phpunit.xml. more info

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">../web/modules/custom/loft_core</directory>
            <exclude>
                <file>../web/modules/custom/loft_core/src/StaticContentStreamWrapper.php</file>
            </exclude>
            <!-- By definition test classes have no tests. -->
            <exclude>
              <directory suffix="Test.php">./</directory>
              <directory suffix="TestBase.php">./</directory>
            </exclude>
        </whitelist>
    </filter>
    
  2. Use the CLI flag --coverage-html <directory>

PHPStorm Configuration

--testsuite Unit --filter LoftCoreUnitTest  --coverage-html coverage

./includes ./lib ./modules ../modules ../sites

 </whitelist>