0

I'm unit testing one of my view controllers and wanted to confirm that when a logic branch is hit, the modal view controller that I pop up with present:


viewDidLoad

MWLoginViewController *loginController = [[MWLoginViewController alloc] init];
[self presentModalViewController:loginController animated:YES];

The code is hit in the debugger when I put a breakpoint.

Now how do I test to see if this was launched?


I am trying:

BOOL wasLoginViewController = [[mainVcSUT presentedViewController] isMemberOfClass:          [MWLoginViewController class]];

[Assert isTrue:wasLoginViewController];

NSLog(@"presented VC was: %@", [[mainVcSUT presentedViewController] class]);

The NSLog is telling me view controller was null.

IluTov
  • 6,807
  • 6
  • 41
  • 103
Mark W
  • 3,879
  • 2
  • 37
  • 53

1 Answers1

0

MWLoginViewController *loginController = [[MWLoginViewController alloc] init];

you are creating just an object , does it have it`s own view ? create viewcontroller either initwithnibname or init from storyboard , then check it

plus , you should not load another view from viewDidLoad: method ...

ogres
  • 3,660
  • 1
  • 17
  • 16