PHPStorm从覆盖率中排除测试

Jos*_*ott 5 phpunit code-coverage magento phpstorm

我想知道是否可以将PHPStorm配置为从百分比中排除Test文件夹,因为我的模块的覆盖率是100%,但是Test文件夹将总体价值降低到50%。

测试降低了百分比

这可能无关紧要,但是我也遇到了一个问题,即覆盖率窗口从不显示实际的覆盖率数据,既不在单独的选项卡中也不查看文件本身。

空的覆盖范围数据

可能是我配置错误,或者与我的项目设置有关(基于符号链接的基于作曲家的Magento项目),但是我有点撞墙了。任何建议欢迎。

更新以包含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>
Run Code Online (Sandbox Code Playgroud)

我认为可能是PHPStorm的原因是Coverage的HTML版本可以完美运行,正确地排除了Test文件夹。

正确覆盖HTML视图

Seb*_*ann 3

这与 PhpStorm 无关。您只需为您的项目配置白名单即可。

  • 感谢塞巴斯蒂安的反馈,我实际上已经尝试过,但没有成功。我已经用我的配置和 HTML 覆盖率报告的屏幕截图更新了原始问题,这实际上是正确的,让我相信问题出在 PHPStorm 上。 (2认同)