ios - OCMock expect a method called within another method -
this extremely basic question ocmock expectations. let's have instance method methoda on objecta calls instance method methodb on objecta.
- (void)methoda { [self methodb]; } - (void)methodb { ... }
now, let's want verify partial mock of objecta invokes methoda , methodb. seems should have is:
- (void)test { id mockobjecta = [ocmockobject partialmockforobject:self.objecta]; [[mockobjecta expect] methoda]; [[mockobjecta expect] methodb]; [self.objecta methoda]; [mockobjecta verify]; }
when run test, thinks methoda invoked methodb not invoked. misunderstanding?
thanks help.
you need tell mock forward method call on real object implementation run.
[[[mockobjecta expect] andforwardtorealobject] methoda];
Comments
Post a Comment