Which coroutine dispatcher to inject when testing a Kotlin console
I have a back-end springboot Kotlin app that has some simple coroutine code for parallel IO operations. It looks something like this
@Service
class AccountService(
private val client: ApiClient
private val coroutineDispatcher: CoroutineDispatcher
) {
fun getAccount(): AccountDTO {
return runBlocking(coroutineDispatcher) {
val foo = async {
client.getFoo() //some long operation
}
val bar = async {
client.getBar() //some other operation...