我在CakePHP上的单元测试仍然在运行,但是代码覆盖率已经消失了。我得到的只是“没有要生成覆盖率的文件”。
我们的应用程序当前运行在CakePHP 2.10.15上。我安装了PHPUnit 5.7。运行PHP7。我使用web runner进行测试和覆盖。我已经运行了XDebug 2.7.0beta1。
我们最近的一个升级是不是打破了Cake和PHPUnit之间的某种联系?
发布于 2020-04-23 12:34:55
在你的应用文件夹中创建一个文件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
请注意,只包含您需要的文件和目录,否则将变得非常慢。
https://stackoverflow.com/questions/54382211
复制相似问题