https://kotlinlang.org logo
#coroutines
Title
# coroutines
n

nquinn

03/26/2017, 4:32 PM
is there a way to mock the results of suspending functions using Mockito? Seems as though the argument matchers never properly working because of the manner in which the compiler desugars the tail parameter. ie:
Copy code
fun <T> OngoingStubbing<Deferred<T>>.thenDeferred(value: T) : OngoingStubbing<Deferred<T>> {
    return thenReturn( async(CommonPool) { value })
}

whenever( mockConnection.updateWithParams(sql, params)).thenDeferred(UpdateResult())
returns something i can .await() on just fine, but if I make the signature of the suspend fun updateWithParams(…): UpdateResult vs fun updatedWithParams(..): Deferred<UpdateResult>, I always get null as a result to the mocked function 3 replies I don’t believe that open is necessary on an interface, and it isn’t required for any of my other Kotlin interfaces that aren’t suspending functions that return types