我在 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/
相关文章:
laravel - 在 Scout 中使用更复杂的 where 子句
node.js - 如何在 Nodejs 中将字符串作为读取流对象传递?
c# - 继续获取 "Unable to load DLL ' SQLite.Interop.dll
javascript - PokeAPI : get complex evolution chain
nginx - 使用 apollo 客户端从 nextjs 中的 getInitialProps 方
maven - 如何重定向 maven surefire 插件 stdout*deferred 临时
java - MockMvcRequestBuilders.asyncDispatch 提供一个空的