CakePHP 2代码覆盖率现在显示“没有文件可为其生成覆盖率”

问题描述 投票:3回答:1

我在CakePHP上的单元测试仍然可以运行,但是代码覆盖范围消失了。我得到的只是“没有文件可为其生成报道”。

我们的应用程序当前在CakePHP 2.10.15上运行。我已经安装了PHPUnit 5.7。运行PHP7。我使用网络运行程序进行测试和覆盖。我正在运行XDebug 2.7.0beta1。

我们最近的一次升级是否破坏了Cake和PHPUnit之间的某种联系?

phpunit cakephp-2.0 xdebug
1个回答
0
投票

在您的应用程序文件夹中创建文件phpunit.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd">

        <logging>
            <log type="coverage-text" target="tmp.txt" showOnlySummary="true"/>
        </logging>

        <testsuite name="default">
            <directory suffix="Test.php">tests</directory>
        </testsuite>    

        <filter>
            <whitelist processUncoveredFilesFromWhitelist="false">                
                <!-- directories that you want in code coverage -->
                <directory suffix=".php">app/</directory> 
            </whitelist>
        </filter>

    </phpunit>

对我来说,像这样添加此文件就可以了。有关此xml的更多信息:https://phpunit.de/manual/5.7/en/appendixes.configuration.html

请注意仅包含所需的文件和目录,否则它将变得非常缓慢。

© www.soinside.com 2019 - 2024. All rights reserved.