[英]Symfony Functional Testing: how to understand why the test fails (with a 500 Error)
我正在為在應用程序中注冊新用戶的控制器編寫功能測試。
由於500 HTTP錯誤,我正在編寫的測試失敗。
我正在使用
$response = $client->getResponse();
print_r($response->getContent());exit;
打印HTML以查看發生了什么,但是在我的控制台(PHPStorm)中HTML不完整,所以我不知道發生了什么,也找不到解決它的錯誤。
關於如何了解正在發生的情況以及導致錯誤的原因有什么想法?
也許這些可以幫助您: app/logs
文件夾中有一個test.log
文件,您可以將其刪除,運行測試,當錯誤發生時打開新生成的文件,讀取發生的事情,僅此而已。
或者,您將DebugBundle
添加到AppKernel.php
文件中的registerBundles
方法中,並使用其dump()
方法,如下所示:
// AppKernel.php
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
...
$bundles[] = new \Symfony\Bundle\DebugBundle\DebugBundle();
}
*****
// usage:
public function testSomeAction()
{
.....
$response = $client->getResponse();
dump($response);
die;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.