Open szaske opened 6 years ago
argumentCaptor()
returns an KArgumentCaptor
instance, but Mockitos @Captor
expected ArgumentCaptor.
There are two ways to solve it:
Use @Captor
without argumentCaptor()
:
@Captor
lateinit var captor: ArgumentCaptor<DisposableObserver<List<Poi_Domain>>>
Use @KCaptor
of mockito4kotlin.annotation:
import org.mockito4kotlin.annotation.KCaptor
import org.mockito4kotlin.annotation.MockAnnotations
@KCaptor
lateinit var captor: KArgumentCaptor<DisposableObserver<List<Poi_Domain>>>
fun setUp() {
MockAnnotations.initMocks(this)
}
or if you like with argumentCaptor()
:
import org.mockito4kotlin.annotation.KCaptor
import org.mockito4kotlin.annotation.MockAnnotations
@KCaptor
var captor = argumentCaptor<DisposableObserver<List<Poi_Domain>>>()
fun setUp() {
MockAnnotations.initMocks(this)
}
Read more about @KCapture
vs. @Captor
Annotation
Hope I could help.
Why not just drop the annotation and use the argumentCaptor-function.
I'm trying to write a unit test using your library version 2.0.0-RC2 and have the following code:
and it gives me a error: "org.mockito.exceptions.base.MockitoException: @Captor field must be of the type ArgumentCaptor. Field: 'captor' has wrong type"
what am I doing wrong?