mockito / mockito-kotlin

Using Mockito with Kotlin
MIT License
3.11k stars 202 forks source link

add argThat(ArgumentMatcher<T>) function #281

Closed sothawo closed 6 years ago

sothawo commented 6 years ago

this PR adds the Mockito.argThat(ArgumentMatcher<T>) call to this library

nhaarman commented 6 years ago

Thanks! Can you provide a test that shows a use case where this is necessary and the existing argThat function doesn't suffice?

sothawo commented 6 years ago

I added some tests. I came upon this when answering a question on SO (https://stackoverflow.com/questions/52005773/match-varargs-in-mockito-2-stubbing/52016020) where the need came up to have a vararg matcher tha can answer questions like does any of the args apply to some predicate or do all have the same predicate. For this one would need to pass in an ArgumentMatcher instance that keeps state.

nhaarman commented 6 years ago

Thanks! I'll make some minor modifications and will merge it in.