22

I am new to easymock.

I am trying to mock a service where one of the methods is a void method that will get called an unknown (and large) number of times. How do I specify that any number of calls is allowed?

I know how to do it for methods that have a non-void return type.

Thanks

Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250
Hendrik
  • 1,355
  • 3
  • 11
  • 30

1 Answers1

38

Call the void method of the mock. Afterwards use EasyMock.expectLastCall().anyTimes()

Arne Burmeister
  • 20,046
  • 8
  • 53
  • 94
  • 8
    Probably better to use EasyMock.expectLastCall().atLeastOnce(), just to make sure the method is actually called. I tend to use for all expectations because it makes your tests less brittle to internal changes that don't effect behavior. – Nick Holt Aug 03 '09 at 12:39