main.kotlin.com.intuit.playerui.utils.test.RunBlockingTest.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testutils Show documentation
Show all versions of testutils Show documentation
A cross-platform semantic rendering engine
package com.intuit.playerui.utils.test
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
/**
* Simple testing extension to ensure suspended tests have a timeout. It's important to understand that this
* only works if coroutines are [cooperative](https://kotlinlang.org/docs/cancellation-and-timeouts.html#cancellation-is-cooperative).
*/
public fun runBlockingTest(timeout: Long = 10000, block: suspend CoroutineScope.() -> T): T = runBlocking {
withTimeout(timeout) {
block()
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy