I'm trying to set some unit test in our huge project. The problem is that some ViewControllers when called partial mock crash with following trace:
error: -[EspionageViewControllerTests testFillEspionageTabInfo] : failed: caught "NSInternalInconsistencyException", "-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "EspionageViewController" nib but the view outlet was not set."
0 CoreFoundation 0x0000000111264f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000110efdbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000111264e6d +[NSException raise:format:] + 205
3 UIKit 0x000000010f68805f -[UIViewController _loadViewFromNibNamed:bundle:] + 441
4 UIKit 0x000000010f688588 -[UIViewController loadView] + 109
5 UIKit 0x000000010f6887f9 -[UIViewController loadViewIfRequired] + 75
6 UIKit 0x000000010f688c8e -[UIViewController view] + 27
7 AppName 0x000000010c07c388 -[IOViewController setTopBarView:] + 1144
As I understand I had problems with setTopBarView, and especially a place where I made following:
[viewElement setFrame:CGRectMake(viewElement.frame.origin.x, self.view.bounds.origin.y - viewElement.frame.size.height , viewElement.frame.size.width, viewElement.frame.size.height)];
So the self.view call makes this crash. My question is how can I avoid this situation - especially when my EspionageViewController is subclass of another ViewController where setTopBarView is defined. I need to use OCMPartialMock on EspionageVC as otherwise I won't be able to check it's methods, however it's super class(and methods) must be fully mocked to prevent those crashes. Any help will be apreciated.
Aucun commentaire:
Enregistrer un commentaire