Is there any way to test getAccessToken() method t...
# coroutines
s
Is there any way to test getAccessToken() method through mockito,
Copy code
getAccessToken(): String {

    val token: String
    //check token expiry...
    runBlocking {
        token = getToken()
    }
    return token
}

getToken(): String = suspendCoroutine { continuation->
    //get the token from server and return it
    continuation.resume(newToken)
}
I tried to mock the getToken() method, but the runBlocking{} block never gets called.
j
Check Mockk library, it has support for coroutines
e
Yeah, mockito doesn’t have the best coroutine support, better to use mockk like @Javier said