0
我正在將Behat與HipChat集成,到目前爲止我已經得到了以下代碼。在Behat測試步驟中顯示返回的具體錯誤
/**
* Send an alert to HipChat when a test fails
*
* @AfterStep
*/
public function notifyHipchat(Behat\Behat\Event\StepEvent $event)
{
if ($event->getResult() === Behat\Behat\Event\StepEvent::FAILED) {
$step = $event->getStep();
$feature = $step->getParent()->getFeature()->getTitle();
$scenario = $step->getParent()->getTitle();
$step = $step->getType() . ' ' . $step->getText();
$error = '!!!!NEED CODE FOR THIS!!!!';
$current_page = $this->getSession()->getCurrentUrl();
$message =
'<img src="http://dl.dropboxusercontent.com/u/9451698/fail.gif" width="32" height="32" /> <strong>Whoopsie! There was a test failure!</strong>' . "<br>" .
'<strong>Domain:</strong> <a href="'.$this->getMinkParameter('base_url').'">' . $this->getMinkParameter('base_url') . "</a><br>" .
'<strong>Test Instance:</strong> ' . $this->getMinkParameter('files_path') . "<br>" .
'<strong>Feature/Test:</strong> ' . $feature . "<br>" .
'<strong>Scenario:</strong> ' . $scenario . "<br>" .
'<strong>Step:</strong> ' . $step . "<br>" .
'<strong>Current Page:</strong> <a href="'.$current_page.'">' . $current_page . '</a>';
$hipchat_url = 'https://api.hipchat.com/v1/rooms/message?auth_token='.getenv('HIPCHAT_AUTH_TOKEN').'&room_id='.getenv('HIPCHAT_ROOM_ID').'&from=Behat&color=red¬ify=1&message=' . urlencode($message);
$hipchat_message = file_get_contents($hipchat_url);
}
}
這是偉大的工作,但它只返回測試步驟失敗,它並沒有告訴我什麼是實際的錯誤了。如何訪問失敗步驟引發的異常?謝謝!
真的嗎?我已經嘗試了幾次,但是從命令行運行時沒有給出與測試相同的回報。我會再試一次,非常感謝! –
這樣做!輸出結果並不像控制檯那麼簡潔,但是我可以將其分解爲我所需要的。非常感謝! –