php - 为什么 PHPUnit + pcov 不生成代码覆盖率统计信息?
问题描述
我将 PHPUnit 配置为使用 XDebug 生成代码覆盖率统计信息。看到 PCOV 更快,我禁用xdebug.so
并安装了pcov.so
.
现在,每当我运行单元测试时,生成的覆盖率报告都没有数字或名称或任何东西:
这是调用 phpunit 的脚本:
#!/bin/bash
script_dir=$(dirname $0);
php $script_dir/phpunit.phar --coverage-html ../../public/coverage
这是我的 phpunit.xml,它在从 XDebug 迁移到 PCOV 的过程中没有改变:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="bootstrap.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">../../app/</directory>
</include>
<exclude>
<directory suffix=".php">../../app/config/</directory>
<directory suffix=".php">../../app/libs/</directory>
<directory suffix=".php">../../app/views/</directory>
</exclude>
</coverage>
</phpunit>
这是输出:
PHPUnit 9.5.6 by Sebastian Bergmann and contributors.
Runtime: PHP 7.3.11 with PCOV 1.0.9
Configuration: /path/to/phpunit.xml
.............. 14 / 14 (100%)
Time: 00:00.751, Memory: 20.00 MB
OK (14 tests, 38 assertions)
Generating code coverage report in HTML format ... done [00:00.074]
PHP 版本:7.3.11
PHPUnit 版本:9.5.6
PCOV 版本:1.09
是否需要为 PCOV 或 PHPUnit 进行一些额外的配置才能使覆盖率报告有用?
解决方案
推荐阅读
- excel - 根据多个条件计算前 3 名产品的每日平均销售额
- r - 使用基因符号可视化 gseKEGG 结果
- reactjs - 无法设置反应项目
- android-studio - 为什么我的文本时钟视图不显示秒,只有分钟和小时
- php - 图像未在 Laravel 8 视图中显示
- angular - DOM 不使用 componentFactory 渲染
- reactjs - reactjs - 使用 xlsx 样式将数据导出到 xlsx 文件
- tomcat - HttpServletRequest#getParameter() 提取时间超过 10 秒
- pygame - 代码异常导致奇怪的俄罗斯方块生成动作
- python - NameError:未定义名称“OutOfBoundsDatetime”