php - Phpunit coverage-text 未显示所有测试的类文件
问题描述
我在我的项目中运行 phpunit,但覆盖文本没有在白名单中显示文件夹内的所有类。
我尝试过使用 PHPUnit 7.5.12 和 PHPUnit 8.2.1。
我尝试过使用 PHP 7.2 和 7.3(我现在正在使用 7.3)
Xdebug 版本为 v2.7.2
我的 phpunit.xml:
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Api Connector">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
如您所见,并非我的项目中的所有文件都显示在覆盖结果中,我不知道为什么。
事实上,tests 目录中的所有文件都经过了测试,因为测试的 114 个函数中有一些是覆盖结果中未显示的文件中的函数。
编辑:Entity 文件夹中的所有文件都扩展了 ApiRest.php,这是一个抽象类。覆盖摘要中未显示的文件是那些没有自定义功能的文件。例如,如果我覆盖 ApiCompany.php 中的函数,则 ApiCompany 会显示在覆盖范围摘要中。
解决方案
推荐阅读
- javascript - 如何在最小值和最大值之间对齐范围滑块中的数据标签
- optaplanner - OptaPlanner,构建需要从解决方案中获取信息的规则
- flyway - 有什么方法可以根据已安装的排名而不是版本撤消 Flyway 吗?
- reactjs - 在 React 中没有从 useHistory 接收道具
- python - Python/Pandas Str.split 在没有拆分时返回 NAN
- spring-boot - 如何跟踪用户活动并将其发送到数据库
- regex - 如果字符串包含列表中的单词,则从字符串中提取单词
- excel - 如何强制 Active-X 组合框从溢出的数组中刷新其下拉列表
- excel - VBA - 根据工作表标签颜色更改特定单元格值的字体颜色
- ruby - 如何从模块下的目录中移动所有类?