Belirli bir işlemin bir modal izleme denetleyicisinin görüntülenmesiyle sonuçlandığını gösteren bir entegrasyon testi oluşturmak istiyorum. Hikaye panosu, 2 adet Viewcontroller, bir tane özel ViewController sınıfı ile ikinci bir UIViewController sınıfı ve "second" başlığı ile ayarlanır. Segue, tanımlayıcı "modalsegue" ile modal olmaya ayarlanmıştır. Uygulamayı simülatörde çalıştırmak harika bir şekilde çalışıyor, ancak doğru bir testi tanımlamakta çok fazla sorun yaşıyorum.Otomatik testlerin testi
ViewController.m:
@implementation ViewController
- (IBAction)handleActionByPerformingModalSegue {
[self performSegueWithIdentifier:@"modalsegue" sender:self];
}
@end
Testi:
- (void)testActionCausesDisplayOfSecondViewController {
ViewController * vc =
[[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]
instantiateViewControllerWithIdentifier:@"ViewController"];
[vc handleActionByPerformingModalSegue];
STAssertEquals(vc.presentedViewController.title, @"second",
@"Title of presented view controller should be second but is %@",
vc.presentedViewController.title, nil);
}
aşağıdaki çıktıda test sonuçlarını Koşu: Neyi yanlış yapıyorum
2013-06-23 17:38:44.164 SeguesRUs[15291:c07] Warning: Attempt to present <UIViewController: 0x7561370> on <ViewController: 0x7566590> whose view is not in the window hierarchy!
SeguesRUsTests.m:33: error: -[SeguesRUsTests testActionCausesDisplayOfSecondViewController] : '<00000000>' should be equal to '<9c210d07>': Title of presented view controller should be second but is (null)
? İlk mesajdan kaçınmanın kolay bir yolu var mı?
iyi, muhtemelen daha yüksek bir seviye çerçevesi geçmesi gereken aslında olacak bir test UI ve bazı iç yöntemler - frank-salatalık örneği Apple'ın UI Otomasyon. – Sulthan