OCMock expect a method called within another method

This is an extremely basic question about OCMock expectations. Let's you have an instance method methodA on objectA that calls an instance method methodB on objectA.

- (void)methodA {
    [self methodB];

- (void)methodB {

Now, let's say I want to verify that a partial mock of objectA invokes methodA and methodB. It seems like all you should have to do is:

- (void)test {
   id mockObjectA = [OCMockObject partialMockForObject:self.objectA];
   [[mockObjectA expect] methodA];
   [[mockObjectA expect] methodB];

   [self.objectA methodA];

   [mockObjectA verify];

When I run the test, it thinks that methodA was successfully invoked but that methodB was not successfully invoked. What am I misunderstanding?

Thanks for the help.


You need to tell the mock to forward the method call on to the real object so the implementation will actually run.

[[[mockObjectA expect] andForwardToRealObject] methodA];

Need Your Help

remap Spring MVC dispatcherServlet via annotations to some other path

spring spring-mvc

I was wondering if it would be possible via annotations remap Spring MVC dispatcherServlet from "/" to some other path ?

Hibernate Annotation Mapping Exception in Spring MVC “org.hibernate.PropertyAccessException”

hibernate spring-mvc jpa hibernate-onetomany

I am new for both Spring MVC and Hibernate. I tried to implement Hibernate annotation based mapping in Spring MVC to add a column into tables Users and Address using @OneToMany bidirectional annota...