Skip to content

Using runBlockingTest

Devrath edited this page Jul 3, 2021 · 1 revision

Defining where to use runBlockingTest

  • We use runBlockingTest to test co-routines that start with launch and async.
  • We use this to test the suspend functions

Testing regular suspend functions

  • Usually the co-routines involve delay so simulating this in a test is essential since it is different than normal functions that we test.
  • Any calls to the delay will automatically advance virtual time by the amount of delay

Gradle

testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.0'
Clone this wiki locally