0

I've tried swizzling out the init method for a partial mock and was wondering if this was possible.

I've had no luck with:

SomeClass *foo = [SomeClass alloc];
mock = [OCMockObject partialMockForObject:foo];
[[[mock stub] andCall:@selector(mockInit) onObject:self] init];

...

[foo init];
Brian Liang
  • 7,734
  • 10
  • 57
  • 72

1 Answers1

1

When you call the init method, you shall it on your mock instance. I think it will work if you do this:

SomeClass *foo = [SomeClass alloc];
mock = [OCMockObject partialMockForObject:foo];
[[[mock stub] andCall:@selector(mockInit) onObject:self] init];

...

[mock init];

Regards, Quentin

Quentin
  • 1,741
  • 2
  • 18
  • 29