https://kotlinlang.org logo
#ktor
Title
# ktor
r

rsetkus

02/16/2021, 2:19 PM
Hi. Is there any way I could mock long running request using MockEngine? Writing a test where I want to test how my code performs at cancellation.
e

e5l

02/16/2021, 2:37 PM
Hey @rsetkus, could you add
delay
call to handler?
r

rsetkus

02/16/2021, 2:42 PM
Hi @e5l. You mean something like this?
Copy code
TEST_DELAY_URL -> {
    delay(2000)
    respondOk()
}
^ this is inside
addHandler
,
when
clause
e

e5l

02/16/2021, 2:49 PM
Yep
r

rsetkus

02/16/2021, 2:55 PM
I guess it worked out. I am getting
java.util.concurrent.CancellationException: StandaloneCoroutine was cancelled
which is expected result to get when coroutine is at suspension point.
18 Views