All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.kotlin.com.intuit.playerui.utils.test.RunBlockingTest.kt Maven / Gradle / Ivy

There is a newer version: 0.10.0-next.7
Show newest version
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