Can I use coroutines to speed up unit tests of sle...
# coroutines
s
Can I use coroutines to speed up unit tests of sleep/delay code versus a blocking approach ? If so are there any resources on this? The coroutines guide doesnt really mention anything.
l
@spand Make a
runBlocking
test method thats runs all the tests that can be parallelized concurrently
s
Say I have some code that sleeps / calls delay with 30 seconds. It would be nice if that could be sped up somehow
I have not used coroutines before but figured it might have some test tools for this case
d
There's currently an open pull request for that
v
We have
TestCoroutineContext
in develop branch with artificial time which can be moved forward. Will be available in the next release. https://github.com/Kotlin/kotlinx.coroutines/pull/297/files
👏 1
🎉 4
d
When is the next release planned for? It's been a while and alot of issues and pull requests are open... I'm sure it's not easy juggling all the different projects at JB, but this seems like one that's constantly increasing in popularity... 😃
s
Sweet. Looks like what I had in mind
s
I hope it can help you out. It works well for us for writing unit-test using coroutines.
s
Whats the easiest way to start using it atm ?
l
@spand Probably copy pasting into your project