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

junit.junit4.CoroutinesTimeoutStatement.kt Maven / Gradle / Ivy

There is a newer version: 1.10.1
Show newest version
package kotlinx.coroutines.debug.junit4

import kotlinx.coroutines.debug.*
import org.junit.runner.*
import org.junit.runners.model.*
import java.util.concurrent.*

internal class CoroutinesTimeoutStatement(
    private val testStatement: Statement,
    private val testDescription: Description,
    private val testTimeoutMs: Long,
    private val cancelOnTimeout: Boolean = false
) : Statement() {

    override fun evaluate() {
        try {
            runWithTimeoutDumpingCoroutines(testDescription.methodName, testTimeoutMs, cancelOnTimeout,
                { TestTimedOutException(testTimeoutMs, TimeUnit.MILLISECONDS) })
            {
                testStatement.evaluate()
            }
        } finally {
            DebugProbes.uninstall()
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy