[ACCEPTED]-java.lang.IllegalStateException: incompatible return value type-easymock

Accepted answer
Score: 17

I just had the same problem.

I had a partial 4 mock in EasyMock, but forgot to call addMockedMethod for the method 3 I wanted to set the expectation for.

The 2 error message was the same as above, I'd 1 say that was somewhat misleading.

Score: 9

In my case the method was final on which I called 2 expect on. So EasyMock was not able to mock the method 1 and thus did not record the method invocation.

Score: 6

Make sure that your entity object is not a simple 2 POJO (eg. new Entity()), and it was created with the 1 createMock() methods of EasyMock.

Score: 3

For me, I had to remember to call reset(...) on 3 it after having used it once, or I (bizarrely) got 2 this error message calling expect on it 1 a second time.

More Related questions