PHPUnit 命令列工具透過 phpunit 指令調用:
phpunit ArrayTest PHPUnit 2.3.0 by Sebastian Bergmann. Time: 0.067288 OK (2 tests)
.:測試成功F:斷言失敗E:發生錯誤I:測試未完成或未實現PHPUnit 區分失敗與錯誤:失敗為斷言例外,錯誤為非預期例外或 PHP 錯誤。錯誤較易修正,建議先解決所有錯誤再處理失敗。
phpunit --help PHPUnit 2.3.0 by Sebastian Bergmann. Usage: phpunit [switches] UnitTest [UnitTest.php] --coverage-data <file> 原始格式寫入代碼覆蓋率資料 --coverage-html <file> HTML 格式寫入代碼覆蓋率資料 --coverage-text <file> 文字格式寫入代碼覆蓋率資料 --testdox-html <file> HTML 格式生成敏捷文檔 --testdox-text <file> 文字格式生成敏捷文檔 --log-xml <file> XML 格式生成測試日誌 --loader <loader> 使用的 TestSuiteLoader 實作 --skeleton 為 Unit.php 中的 Unit 生成骨架 UnitTest 類別 --wait 每個測試後等待按鍵 --help 顯示用法資訊 --version 顯示版本並退出
phpunit UnitTest:運行 UnitTest 類別測試,該類別定義於 UnitTest.phpphpunit UnitTest UnitTest.php:指定源檔案運行測試PHPUnit2_Framework_TestCase 或提供 suite() 靜態方法回傳 PHPUnit2_Framework_Test 物件