dhamini-poornachandra / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

Stubbing consecutive void calls #261

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Correct me if I'm wrong, but apparently Mockito doesn't support chain stubbing 
void methods out of the box.

I mean an equivalent of:

when(myStub.myMethod()).thenReturn("A").thenReturn("B");

I would love to see either of the below in the standard API:

doAsnwer(doThis()).doAnswer(doThat()).when(myStub).myMethod();

doAsnwer(doThis()).thenAnswer(doThat()).when(myStub).myMethod();

doAnswer(chainAnswer(doThis(), doThat()).when(myStub).myMethod();

(The latter is what I ended up implementing myself)

Original issue reported on code.google.com by konrad.g...@gmail.com on 16 May 2011 at 3:36

GoogleCodeExporter commented 8 years ago
Yes you can : 

doAnswer(doThis()).doAnswer(doThat()).when(theStub()).tehMethod();

Original comment by brice.du...@gmail.com on 16 May 2011 at 3:49

GoogleCodeExporter commented 8 years ago
User error, my apologies.

Original comment by konrad.g...@gmail.com on 16 May 2011 at 3:56

GoogleCodeExporter commented 8 years ago
Don't worry, it happens to everyone :)

Original comment by brice.du...@gmail.com on 16 May 2011 at 4:12