I'm in for testing some code within a ViewController (that certain controls are active depending on the state of certain UISwitches etc) and decided to go for Kiwi for it, since we are using it for some other low-level logic testing.
My expectation is to run tests like this:
__block AViewController *aVC;
it(@"(tokenTextField) should be hidden if the token switch is set to off", ^{
lvC.useTokenSwitch.on = false;
[[theValue(aVC.tokenTextField.hidden) should] equal:theValue(YES)];
});
My problem is with the initialisation of the AViewController. If I did:
aVC = [[AViewController alloc] initWithNibName:@"aViewController" bundle:nil];
I would be getting a "AViewController" without any controls initialised, so I'd have to init each of them manually.
So I have tried obtaining the AViewController doing this:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
aVC = [storyboard instantiateViewControllerWithIdentifier:@"AViewController"];
Yet this results in an error message:
NSInvalidArgumentException "Could not find a storyboard named 'MainStoryboard' in bundle NSBundle </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/Developer/usr/bin> (loaded)" raised
I have included the MainStoryboard in my testing target, and also included it in "Build Phases" -> "Copy Bundle Resources" and still nothing.
So I am wondering if it is even possible to instantiate a ViewController from a Storyboard in a Kiwi Testing Target? (As I haven't seen any examples of it anywhere).
Is my approach wrong and I should be mocking the ViewController?
Am I missing something to be included in the test target?