2014-05-15 2 views
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" />&nbsp;&nbsp;<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&notify=1&message=' . urlencode($message); 
     $hipchat_message = file_get_contents($hipchat_url); 
    } 
} 

위대한 기능을 수행하고 있지만 실패한 테스트 단계 만 반환하기 때문에 실제로 오류가 무엇인지 알 수 없습니다. 실패한 단계에서 발생한 예외에 어떻게 액세스합니까? 감사!

답변

1

그것은 정말

$event->getException() 
+0

입니까? 몇 번 시도해 봤지만 명령 줄에서 실행할 때와 동일한 결과를 얻지 못했습니다. 나는 그것을 또 한번 시도해 볼 것이고, 그렇게 많이 고맙다 !! –

+0

그랬어 !! 출력은 콘솔만큼 간결하지는 않지만 필자는 필자가 필요로했던 것을 제거 할 수있었습니다. 정말 고마워! –