2013-08-23 5 views
2

:의 ViewController 더 식별자 SEGUE이 없습니다단위 테스트 : 나는 방법을 아래에 테스트 할 "SEGUE ID"

- (void)testMyMethod 
{ 
    // Call method to test 
    [testClass myMethod]; 

    // Tests 
    GHAssertNil(testClass.contact, @"contact should be nil."); 
} 

테스트를 실행 :

- (void)myMethod 
{ 
    self.contact = nil; 
    [self performSegueWithIdentifier:@"segue id" sender:self]; 
} 

이것은 내가 테스트 클래스에서 할 것입니다 나에게 오류를 준다 :

Reason : Receiver (<RS_MainViewController:0x126b6330>) has no segue with identifier 'segue id' 

왜 나는이 오류가 발생하고 해결책은 무엇입니까?

+0

스토리 보드에서 해당 단절의 segue id를 지정 했습니까? – JPetric

+0

@JPetric 예. 있습니다. – Geek

답변

0

내 테스트에서 스토리 보드의보기 컨트롤러를로드해야만했습니다. 나는 내 테스트에서 viewDidLoad로 전화를 걸어 계속 할 수 있었다.

UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard" bundle:nil]; 
UIViewController* controller = [storyboard instantiateViewControllerWithIdentifier:@"MyViewControllerId"]; 
AAAMyViewController* viewController = (AAAMyViewController*)controller; 

또한 스토리 보드에 들어가서이보기 컨트롤러 (MyViewControllerId)의 스토리 보드 ID를 추가해야했습니다.