为了账号安全,请及时绑定邮箱和手机立即绑定

为什么 PHPUnit 9 不期望记录 phpunit.xml.dist 的 log 子元素

为什么 PHPUnit 9 不期望记录 phpunit.xml.dist 的 log 子元素

PHP
弑天下 2023-10-21 15:56:37
我正在致力于将 PHP 应用程序(超过 10 年)过渡到 PHP 7.4,我们目前正在应用程序的 PHP 7.4 分支上实现持续集成。我们决定使用 PHP 当前稳定版本支持的 PHPUnit 版本。因此我们将 PHP 7.4 分支的 ci 测试工作升级到了 PHPUnit 9.3。我们根据文档进行了所有必要的更改,但我们因一个不知道如何修复的警告而被阻止(假设执行了测试并且在正确的位置发布了报告)  Warning - The configuration file did not pass validation!  The following problems have been detected:  Line 38:  - Element 'log': This element is not expected..我在下面分享我们的 PHPUnit 配置以及我们用来启动它的命令,有人能发现它有什么问题吗?phpunit -c phpunit.xml.dist<?xml version="1.0" encoding="UTF-8"?><phpunit    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.3/phpunit.xsd"    colors="true"    bootstrap="tests/bootstrap.php">    <testsuites>        <testsuite name="Unit Tests">            <directory>tests/</directory>        </testsuite>    </testsuites>    <coverage>        <include>            <directory suffix=".php">api</directory>        </include>    </coverage>    <logging>        <log type="junit" target="build/unit_report.xml"/>    </logging></phpunit>
查看完整描述

2 回答

?
慕尼黑5688855

TA贡献1848条经验 获得超2个赞

<log>元素在 PHPUnit 9.3 中也发生了变化。

你需要改变


<logging>

  <log type="junit" target="build/unit_report.xml"/>

</logging>


<logging>

  <junit outputFile="build/unit_report.xml"/>

</logging>

话虽这么说,我强烈建议使用 PHPUnit 的--migrate-configurationCLI 选项自动将您的配置文件转换为新格式。


查看完整回答
反对 回复 2023-10-21
?
慕田峪7331174

TA贡献1828条经验 获得超13个赞

PHPUnit 9.5.x 中已更改


尝试以下任何一个


<logging>

    <testdoxHtml outputFile="tests/coverage.html"/>

    <testdoxXml outputFile="tests/coverage.xml"/>

    <text outputFile="tests/coverage.txt"/>

</logging>


查看完整回答
反对 回复 2023-10-21
  • 2 回答
  • 0 关注
  • 112 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信