File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to understand : No Last Call on a Mock available. _ Easy Mocks

 
Ravi C Kota
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

While I was working on some unit tests using EasyMock, I ended up with the exception java.lang.IllegalStateException: no last call on a mock available, quite often.

Below is the program, that needs to be tested.



Now I need to write some unit tests for Main and mocking IInterface, for now

My code is as follows


I need to admit that I have not worked on EasyMocks before and pretty good chances that I did not set it up correctly in my test. But then, I need guidance in setting up the test correctly.

I'm using EasyMock 3.0.

When I ran my test, it is failing with the exception java.lang.IllegalStateException: no last call on a mock available, pointing at line

EasyMock.expect(a.function()).andReturn("test");

Can somebody guide me ?

Thanks
 
Ravi C Kota
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some guidance please.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you call EasyMock.replay(a) ?

Without calling replay, the mock stays in record mode. Then when you call the actual method, the mock is recording and wonders what the return value should be.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic