PHPStorm exclude Tests from coverage percentage

Stefan Bogdanescu
Founder & Senior Architect · 18 October 2026

Configuring PHPStorm for Code Coverage Exclusion


As a senior developer specializing in Laravel applications on LaravelCompany, I frequently encounter challenges related to configuring PHPStorm’s code coverage features. In this post, we will address the common issue of excluding the Test folder from the overall coverage percentage calculation.

Understanding the Problem

PHPStorm is a powerful IDE that offers robust support for PHP development, including integrated code coverage analysis. However, when working on large-scale projects, it is not uncommon to have test-related files (e.g., Test folders) dragging down the overall coverage percentage, even though your actual module has been thoroughly tested and covered.

In your case, you’re dealing with two main issues:

  1. The Test folder is bringing down the overall code coverage from 100% to an average of around 50%.

  2. The coverage window in PHPStorm fails to display any actual data, neither in the separate tab nor when viewing individual files.

Potential Causes and Solutions

Mis-configuration of PHPStorm settings The most likely culprit for your issue is a misconfiguration within PHPStorm itself or the project’s phpunit.xml file. To resolve this:

  • Double-check that you have correctly configured the code coverage settings in PHPStorm.
    • Go to File > Settings (or Preferences on macOS).
    • Navigate to Languages & Frameworks > PHP > Servers and add a new server configuration if necessary.
    • Ensure the “Code Coverage” tab is properly set up, with the correct paths for your project’s sources and tests.

Project structure complexities Since you mentioned having a composer-based Magento project with symlinking, the complex project setup might be causing PHPStorm to misinterpret certain files or folders. To address this:

  • Verify that your phpunit.xml file is correctly configured.
    • Check if there are any missing or incorrect paths in the configuration.

Incorrect exclusions in phpunit.xml Let’s examine your provided phpunit.xml configuration and identify potential issues.

<phpunit cacheTokens="true"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         stopOnError="false"
         stopOnFailure="false"
         stopOnIncomplete="false"
         stopOnSkipped="false"
         strict="false"
         stderr="true"
         verbose="false"
         bootstrap="app/code/community/EcomDev/PHPUnit/bootstrap.php">
    <listeners>
        <listener file="app/code/community/EcomDev/PHPUnit/Test/Listener.php" class="EcomDev_PHPUnit_Test_Listener"/>
    </listeners>
    <testsuite name="Magento Test Suite">
        <file>app/code/community/EcomDev/PHPUnit/Test/Suite.php</file>
    </testsuite>
    <filter>
        <blacklist>
            <!-- Exclude Magento Core files from code coverage -->
            <directory suffix=".php">app/code/core</directory>
            <!-- Exclude EcomDev_PHPUnit classes from code coverage -->
            <directory suffix=".php">app/code/community/EcomDev/PHPUnit</directory>
            <!-- Additional exclusions -->
        </blacklist>
    </filter>
    <logging>
        <log type="coverage-html" target="var/phpunit/coverage" charset="UTF-8" yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/>
        <log type="coverage-clover" target="var/phpunit/coverage.xml"/>
        <log type="junit" target="var/phpunit/junit.xml" logIncompleteSkipped="false"/>
    </logging>
</phpunit>

Recommendations for Configuration

  • Ensure that the <filter> section contains the appropriate <blacklist> entries to exclude both Magento core files and EcomDev_PHPUnit classes from code coverage.

  • Double-check that you have excluded the correct directories and files in your project’s phpunit.xml configuration, especially those related to test cases.

Conclusion

In most cases, misconfigurations within PHPStorm or the phpunit.xml file are responsible for issues like these. By thoroughly reviewing your settings and ensuring proper exclusions in the configuration file, you should be able to resolve both problems – displaying accurate code coverage data and excluding the Test folder from the overall percentage.

Remember that maintaining a clean and well-structured project is crucial for PHPStorm’s effective integration with your development workflow. Regularly review and update your configuration files to ensure they align with your project’s requirements and dependencies.

For more in-depth guidance on PHPStorm configurations and Laravel application development, feel free to explore our comprehensive resources at LaravelCompany.

Our network