Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalStateException: incompatible return value type

I am using EasyMock to create mock classes in test cases.

expect(entity.getType()).andReturn("string");

Type belongs to the String datatype. In my development environment it is working fine. But If I transfer to my server and take build, it is failing with following error:

java.lang.IllegalStateException: incompatible return value type

I don't know why it is failing in server and getting executed in my development machine.

Development EasyMock version: 2.5.2

like image 936
Dinesh Avatar asked Mar 11 '11 06:03

Dinesh


2 Answers

I just had the same problem.

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

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

like image 153
Björn Avatar answered Oct 02 '22 12:10

Björn


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

like image 32
Eduard Wirch Avatar answered Oct 02 '22 12:10

Eduard Wirch