There are two possible workarounds:
private fun <T> anyObject(): T {
Mockito.anyObject<T>()
return uninitialized()
}
private fun <T> uninitialized(): T = null as T
@Test
fun myTest() {
`when`(mockedBackend).login(anyObject())).thenAnswer { ... }
}
The other workaround is
private fun <T> anyObject(): T {
return Mockito.anyObject<T>()
}
@Test
fun myTest() {
`when`(mockedBackend).login(anyObject())).thenAnswer { ... }
}
Here is some more discussion on this topic, where the workaround is first suggested.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…