Search code examples
javaunit-testingjakarta-eeeasymock

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


Solution

  • 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.