解決 PHPUnit 測試遇到 OK, but there were issues!

PhpStorm 執行 PHPUnit 測試遇到「OK, but there were issues!」在命令列指令加上「--display-deprecations」就可以顯示完整的錯誤資訊。

Made with DALL-E

問題狀況

執行 PHPUnit 測試遇到土黃色訊息「OK, but there were issues!」


解決方式

1. 複製 PHPUnit 的終端機指令

PhpStorm 顯示測試結果的對話窗格,往上捲到頂端


複製指令例如:(以下已經簡化,請自行修改 PHP 路徑與專案路徑)

/path/to/php /path/to/project/phpunit.phar --configuration /path/to/project/phpunit.xml --teamcity

在最後面加上 --display-deprecations

/path/to/php /path/to/project/phpunit.phar --configuration /path/to/project/phpunit.xml --teamcity --display-deprecations

2. 開啟終端機 APP (terminal) 

3. 將指令貼到終端機 APP

會重複執行 PHPUnit 測試,最後結果會顯示出現完整已棄用語法的錯誤 (deprecations) 與程式碼行號。

4. 修正錯誤

修正已棄用語法的錯誤後,回到終端機 APP 或 PhpStorm,執行同樣的指令,就會出現想要的綠色 OK 訊息。


參考資料

Detailed information, for instance which issue was triggered where, is only printed when --display-deprecations, --display-notices, or --display-warnings is used:



留言