infinite / mockito-flex

0 stars 0 forks source link

Optional parameters handling #24

Open infinite opened 10 years ago

infinite commented 10 years ago

it would be nice if you didn't have to specify every variation of optionally passed parameters. To make the above bulletproof I have to do this:

mockito.given( myDelegate.addEventListener( mockito.any(), mockito.any() ) ).will( mockito.callOriginal() ); mockito.given( myDelegate.addEventListener( mockito.any(), mockito.any(), mockito.any() ) ).will( mockito.callOriginal() ); mockito.given( myDelegate.addEventListener( mockito.any(), mockito.any(), mockito.any(), mockito.any() ) ).will( mockito.callOriginal() ); mockito.given( myDelegate.addEventListener( mockito.any(), mockito.any(), mockito.any(), mockito.any(), mockito.any() ) ).will( mockito.callOriginal() ); mockito.given( myDelegate.dispatchEvent( mockito.any() ) ).will( mockito.callOriginal() );

perhaps an anyOrNone() call would sort that:

mockito.given( myDelegate.addEventListener( mockito.any(), mockito.any(), mockito.anyOrNone(), mockito.anyOrNone(), mockito.anyOrNone() ) ).will( mockito.callOriginal() ); mockito.given( myDelegate.dispatchEvent( mockito.any() ) ).will( mockito.callOriginal() );