magento - PHPStorm 从覆盖百分比中排除测试

标签 magento phpunit code-coverage phpstorm

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

Tests bringing percentage down

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

Empty coverage data

可能是我配置错误,或者与我的项目设置有关(基于 Composer 的带有符号链接(symbolic link)的 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>

我认为它可能是 PHPStorm 的原因是 HTML 版本的覆盖工作完美,正确地排除了 Test 文件夹。

Correct coverage in HTML view

最佳答案

这与 PhpStorm 无关。您只需要配置一个whitelist为您的项目。

关于magento - PHPStorm 从覆盖百分比中排除测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30891018/

相关文章:

unit-testing - 是否有用于 TSQL sproc 单元测试的代码覆盖工具?

php - 如何在所有测试完成之前显示失败的 PHPUnit 测试的名称

unit-testing - 在 GO 中测试 - 项目包中的代码覆盖率

php - .htaccess。拒绝 root,允许特定的子文件夹。可能的?

magento - 通过 SOAP API V2 将简单产品链接到可配置产品

php - 如何在 Magento 中获取订单的完成日期

magento - 在 Magento 电子邮件模型中添加密件抄送

php - 通过 PEAR 安装 PHPUnit

git - 使用 Gitlab 持续集成设置 PHPUnit

code-coverage - 通过 ant 在 cobertura 中故障线路覆盖率(100%)?