问题描述
我目前正在将旧的PHP应用程序(olf超过10年)过渡到PHP 7.4,我们目前正在该应用程序的PHP 7.4分支上实现持续集成。我们决定使用PHP当前稳定版本支持的PHPUnit版本。因此,我们将PHP 7.4分支的ci测试工作升级到PHPUnit 9.3。
我们已根据文档进行了所有必要的更改,但由于一则警告我们不知道如何解决而被阻止(请确保执行了测试,并在正确的位置发布了报告) 警告-配置文件未通过验证!
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>
解决方法
PHPUnit 9.3中的<log>
元素也有changed。
您需要更改
<logging>
<log type="junit" target="build/unit_report.xml"/>
</logging>
到
<logging>
<junit outputFile="build/unit_report.xml"/>
</logging>
话虽如此,我强烈建议您使用PHPUnit的--migrate-configuration
CLI选项将您的配置文件自动转换为新格式。