mockito-kotlin
mockito-kotlin copied to clipboard
captor.capture() must not be null
trafficstars
I'm trying to use argumentCaptor for inline function. Every time I run the test I'm getting captor.capture() must not be null. Any suggestion?
val captor = argumentCaptor<(Boolean) -> Unit>()
@Before
fun setUp() {
MockitoAnnotations.openMocks(this)
...
}
@Test
fun shouldTestSomething() {
val captor = argumentCaptor<(Boolean) -> Unit>()
viewModel.doSomething(stringParam, captor.capture())
}
You need to make your capture call in your verify not directly and you can't mix values and matchers at one verification