Hi guys, how can I mock suspend function? For exam...
# coroutines
f
Hi guys, how can I mock suspend function? For example, I would like to mock:
Copy code
val mockContextManager = Mockito.mock(ContextManager::class.java)
        Mockito.`when`(mockContextManager.get(1)).thenReturn(2)
where get is a suspend function
e
Use the latest version of Mockito and wrap the
Mockito.mock
invocation into
runBlocking { ... }
f
thanks @elizarov, like that:
Copy code
runBlocking { Mockito.`when`(mockContextManager.get("1") ).thenReturn(mockResultForUser1) 
}
It doesn’t work mockito execute original method