I have a XCTest case with the following code:
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
@interface ChildViewControllerTests : XCTestCase
@end
@implementation ChildViewControllerTests
-(void) testInitAddsPassedControllersAsChildViews {
id mockTVC1 = [OCMockObject niceMockForClass:[UITableViewController class]];
id mockTVC2 = [OCMockObject niceMockForClass:[UITableViewController class]];
UIViewController *controller = [[UIViewController alloc] init];
[controller addChildViewController:mockTVC2]; // Fails if mockTVC2, but mockTVC1 works.
}
@end
It's as simple as I can make it. When I run this test, I get an EXEC_BAD_ACCESS deallocing mockTVC2.
If I add mockTVC1 to the controller instead, it works just fine.
If I swap the order of the mockTVC1 and mockTVC2 declarations, it works just fine.
If I swap the order of the mockTVC1 and mockTVC2 declarations and change to adding mockTVC1, it fails again de-allocing.
So my summation is that the problem has something to do with the declaring of the second mock because no matter how I order the declarations, if I attempt to add the mock declared second to the controller, then it fails when de-allocing.
Can some of you guys do a quick cut-n-paste and see if you get this to occur as well?
I'd like to confirm it's not just my setup.
Thanks