is there a way to introduce a delay that can be sk...
# announcements
m
is there a way to introduce a delay that can be skipped in a test? I tried using
Copy code
runBlocking {
    delay(10000)
}
and then testing it with
runBlockingTest
, but since it’s in another
runBlocking
block the delay is not being skipped and my test is, in fact, hanging for 10 secs. I’d like to test that the delay is indeed executed but without really having to wait for it to expire
f
if you have dependency injection you can inject a mocked instance with the duration of the delay
m
yep that’s kind of my last resort but i was hoping for something less invasive 🙂
g
Only setting dispatcher will help But in general it's already problematic to test properly if you use runBlocking, test suspend, non blocking functions is a lot easier
m
i know, but it’s a camel message handler and they don’t play well with suspend
g
Injecting test dispatcher and use it for runBlocking should work