2017-04-08 13 views
0

TestRail과 기능 테스트 결과를 통합하고 싶습니다. 테스트 레일 승인 상태 업데이트는 테스트가 성공했는지 또는 실패했는지 여부를 의미합니다. 하지만 assertEqual, assertTrue 등의 PHPunit 함수는 값을 반환하지 않습니다. 어떻게 할 수 있습니까?PHPunit과 testrail을 통합하는 방법

public function testGetItem() 
{ 
    $this->specify("Verify the functionality of the method ", function ($itemId, $orgId, $expectedResult) { 

    $result = $this->itemRepository->getItemInfo($ItemId , $orgId); 
    //$this->assertEquals($expectedResult , $result) 
    $testRail=new TestRailIntegration(); 
    if($this->assertEquals($expectedResult , $result)){ 
     $testRail->postResultsToTestRail("34530","1"); 
    } else{ 
     $testRail->postResultsToTestRail("34530",""); 
    } 
    //34530 is testrail id 
} 

테스트가 실패하면 else 조건으로 넘어 가지 않습니다.

답변

1

직접적인 대답은 예외를 포착하고 결과를 게시하고 예외를 다시 발생시키는 것입니다.

public function testGetItem() 
{ 
    $this->specify("Verify the functionality of the method ", function ($itemId, $orgId, $expectedResult) { 

    $testRail = new TestRailIntegration(); 
    try { 
     $result = $this->itemRepository->getItemInfo($ItemId , $orgId); 
     $this->assertEquals($expectedResult, $result); 
     $testRail->postResultsToTestRail("34530", "1"); 
    } catch (\Exception $e) { 
     $testRail->postResultsToTestRail("34530", ""); 
     throw $e; 
    } 
}