• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

expectLastCall().atLeastOnce() what is the use.

 
Ranch Hand
Posts: 157
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

In EasyMock i have seen expectLastCall().atLeastOnce() method but not sure whats the use of it exactly as if i use it inside my test does make any effect. javadoc not providing much help to see the behavior practically.



 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The expectLastCall() method refers to the last expect() called. So for example if you did the second line would be modifying the object returned from the first line so when the method is called it returns a specific value.

Normally an expect() would indicate the method should be called exactly one. But you can tell it to expect the method a certain number of times using the times() method. Our you can say the method must be called at least once, but maybe more than once using the. AtLeastOnce() method.

So in your code you have this


You are saying the method getPath() should be called, when it is called it should return "/content" and it must be called at least once but it is allowed to be called 2 or 3 or any number of times greater than 1.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic