https://kotlinlang.org logo
#mockk
Title
# mockk
h

Hexa

03/16/2019, 8:40 PM
the
GlobalScope.async { "testCarId" }
part seems weird to me I tried
returns  "testCarId"
but I'm getting an incompatible type error
o

oleksiyp

03/16/2019, 11:44 PM
It is hard to understand what you are trying to achieve.
Please explain more.
h

Hexa

03/17/2019, 9:03 AM
yep
parseCarAsync()
is just an async function that returns a string
Copy code
parseCarAsync(test1: String, test2: String) = GlobalScope.async{ 

// make expensive network call here

//return@async  return some string here
}
i just want to mock it and return a fake answers
o

oleksiyp

03/17/2019, 9:03 AM
So the type is actually Deferred
Replacing it with
GlobalScope.async { "something" }
should be exactly what you want. Why there is any doubts about it ?
h

Hexa

03/17/2019, 10:21 AM
Thanks @oleksiyp,
GlobalScope.async { "something" }
syntax just looks weird, why can't I just return Deferred("testCardId") or use any subclass that extends Deferred
o

oleksiyp

03/17/2019, 10:24 AM
Up to you, but this out of scope of mocking framework
More a question to coroutines channel on how to create Deferred simpler
h

Hexa

03/17/2019, 10:35 AM
Thanks @oleksiyp