mockito-collections icon indicating copy to clipboard operation
mockito-collections copied to clipboard

Get mock by index

Open jameskennard opened this issue 11 years ago • 0 comments

When we use the @CollectionOfMocks annotation on a List we can easily retrieve the mocks by their index in the List. However when use the @CollectionOfMocks annotation on a Collection that is not a List, such as a Set or Queue, we cannot retrieve the mocks by index other than iterating over the Collection.

Given that the order of the mocks is guaranteed even in a Set (when using Mockito-Collections). It would be nice to have a convenient way to get a mock by index, something like:

mockAtIndex2 = MockitoCollections.getMock(2, setOfMocks);

Or maybe more fluently:

mockAtIndex2 = MockitoCollections.getMock(2).from(setOfMocks);

jameskennard avatar Jun 15 '13 11:06 jameskennard