views:

1288

answers:

1

I am new to easymock.

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

I know how to do it for other then void methods.

Thanks,

Hendrik

+4  A: 

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

Arne Burmeister
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