Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPStorm exclude Tests from coverage percentage

I am wondering if it is possible to configure PHPStorm to exclude the Test folder from the percentages, since my module has 100% coverage but the Test folder is bringing the overall value down to 50%.

Tests bringing percentage down

This could be unrelated, but I also have an issue where the coverage window never displays the actual coverage data, neither in the separate tab nor viewing the file itself.

Empty coverage data

Chances are I have mis-configured something, or it is something to do with my project setup (composer based Magento project with symlinking) but I'm banging my head against the wall a bit. Any suggestions welcome.

Update to include phpunit.xml:

<?xml version="1.0"?>
<!-- initial phpunit configuration file, that you can modify for your project needs -->
<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>
            <directory suffix=".php">lib/EcomDev/Utils</directory>
            <directory suffix=".php">lib/EcomDev/PHPUnit</directory>
            <directory suffix=".php">lib/Spyc</directory>
            <directory suffix=".php">lib/vfsStream</directory>
            <!-- Exclude Mage.php file from code coverage -->
            <file>app/Mage.php</file>
            <!-- Exclude template files -->
            <directory suffix=".phtml">app/design</directory>
            <!-- Exclude Varien & Zend libraries -->
            <directory suffix=".php">lib/Varien</directory>
            <directory suffix=".php">lib/Zend</directory>
            <directory suffix=".php">lib/Magento</directory>
        </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>

The reason I thought it might be PHPStorm is the fact that the HTML version of the coverage works perfectly, correctly excluding the Test folder.

Correct coverage in HTML view

like image 928
Joseph McDermott Avatar asked Oct 19 '22 09:10

Joseph McDermott


1 Answers

This has nothing to do with PhpStorm. You simply need to configure a whitelist for your project.

like image 90
Sebastian Bergmann Avatar answered Oct 27 '22 12:10

Sebastian Bergmann