This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Testing and the fly likes Unable to understand : No Last Call on a Mock available. _ Easy Mocks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Unable to understand : No Last Call on a Mock available. _ Easy Mocks" Watch "Unable to understand : No Last Call on a Mock available. _ Easy Mocks" New topic
Author

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

Ravi C Kota
Ranch Hand

Joined: Jan 29, 2008
Posts: 61
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


Thanks & Regards, Ravi C.Kota
SCJP 5.0, OCDJWS 5.0
Ravi C Kota
Ranch Hand

Joined: Jan 29, 2008
Posts: 61
Some guidance please.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30050
    
149

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to understand : No Last Call on a Mock available. _ Easy Mocks
 
Similar Threads
EasyMock dummy question
EasyMockClassExtension not mocking class
How to mock Hibernate Session?
Help me in mocking static functions with testng powermock and easymock
Unable to fully utilize EasyMock. Not compliance with Test Driven Approach.