[英]Binding Laravel phpunit tests to routes
我正在使用Laravel 5.1構建RESTful API。 我使用軟件包隨附的默認phpunit編寫了功能測試。 我可以使用phpunit
命令從命令行運行測試。
我想創建一個名為/tests
的路由,並將其綁定到phpunit測試。 因此,在將api部署到服務器之后,當我向http://api.mysite.com/test
發出GET
請求時,我應該獲得測試結果。
那可能嗎 ?
提前致謝。
您可以創建如下路線:
Route::get('tests', array(function () {
$phpunit = new PHPUnit_TextUI_TestRunner;
try {
$test_results = $phpunit->dorun($phpunit->getTest(__DIR__, '', 'Test.php'));
} catch (PHPUnit_Framework_Exception $e) {
print $e->getMessage() . "\n";
die ("Unit tests failed.");
}
}));
來自類似的問題: 您可以從腳本運行PHPUnit測試嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.