我正在致力于將 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 選項自動將您的配置文件轉換為新格式。

慕田峪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>
- 2 回答
- 0 關注
- 185 瀏覽
添加回答
舉報
0/150
提交
取消