gpt4 book ai didi

phpunit - CakePHP 2 代码覆盖率现在显示为 "No files to generate coverage for"

转载 作者:行者123 更新时间:2023-12-05 07:26:20 25 4
gpt4 key购买 nike

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

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

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

最佳答案

在您的应用程序文件夹中创建文件 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

请注意只包含您需要的文件和目录,否则它会变得很慢。

关于phpunit - CakePHP 2 代码覆盖率现在显示为 "No files to generate coverage for",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54382211/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com