• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
Ranch Hand
Posts: 61
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some guidance please.
 
author & internet detective
Posts: 39283
727
Eclipse IDE Java VI Editor
  • 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.
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!