When you encounter this error, please check whether you tried to use the mock object before invoking EasyMock.replay() method. I did that encountered the IllegalStateException and spent quite some time until I figured out the reason.
I had written the following expect() ;
EasyMock.expect(testObj.getTestMethod()).andReturn("testValue");
the culprit was the following statement which I had put before the expect().
System.out.println("testObj="+testObj.getTestMethod());
Hope it helps someone!
That was a big help. Thanks :)
ReplyDeleteBig help, thank you
ReplyDeleteReally helpful. I spent quite some time trying to figure out the solution and I coulnt find it anywhere else. Thanks..!!
ReplyDelete