mockito / mockito-kotlin

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

Warning with `refEq` #328

Closed pablisco closed 5 years ago

pablisco commented 5 years ago

We are testing something that uses OkHttp interceptors and came across an issue that we are not sure how to fix. We have this:

verify(chain).proceed(refEq(expectedRequest))

To make sure the Chain is called with the right request. However, this gives us a Type Mismatch warning because It expects a Request and not Request? as refEq returns.

The only thing that we have tried to do is to add !! at the end to remove the warning but that has woese consequences as it makes the tests fail with a KotlinNullPointerException. Which is understandable since Mockito returns null in their implementation.

Would it be as simple as using ?: createInstance() as it is done on other matchers?

nhaarman commented 5 years ago

Fixed in #329