Is there any known weirdness with the latest stabl...
# coroutines
d
Is there any known weirdness with the latest stable versions of kotlin/coroutines and Mockito? I'm having an issue where my tests are provided mocks, the debugger confirms it's a mock, but the code actually tries to execute in those mocks
j
I'm skeptical that you're describing the problem correctly. Are you using mockito-kotlin? plain old mockito runs into trouble because the matchers all return null and assign the value to possibly non-nullable args. I'm a big fan mockK https://mockk.io/
d
Yes, I'm using mockito-kotlin. I have a VM, where I have a
Repo
which only has
Api
as a dependency of it.
Copy code
lateinit var repo: Repo
   lateinit var vm: VM

repo = mock {onblocking{this.myApiCall()}.thenReturn(result)
vm = VM(repo)

vm.doMethod()
This results in a NPE where
Copy code
open class Repo(api:Api){
  fun myApiCall(){
    val apiResult =  api.makeCall() //Results in NPE
But I would expect for the mock to intercept this and instead just return the value I specified
If I take it a step further, and instead of making the Repo as a mock, but instantiate a real one, and then mock the
Api
then I'm seeing the correct behavior