Skip to content

Instantly share code, notes, and snippets.

@alistairsykes
Created December 10, 2019 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alistairsykes/a6910faf17021a23d77bdccdbf8d7f70 to your computer and use it in GitHub Desktop.
Save alistairsykes/a6910faf17021a23d77bdccdbf8d7f70 to your computer and use it in GitHub Desktop.
// Common
@Suppress("UnusedPrivateMember")
internal expect fun <T> runTest(block: suspend () -> T)
// Android
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runBlockingTest
@UseExperimental(ExperimentalCoroutinesApi::class)
internal actual fun <T> runTest(block: suspend () -> T) {
runBlockingTest { block() }
}
// iOS
import kotlinx.coroutines.runBlocking
internal actual fun <T> runTest(block: suspend () -> T) {
runBlocking { block() }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment