I have a few long-running tests in a Kotlin/JVM project with the dependencies below that defines a non-coroutine test as shown farther down. The @Timeout annotation seems to be ignored. Is there a different way of specifying a timeout for a long running test.
dependencies {
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
...
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5'
...
}
From settings.gradle
gradle.ext.kotlin_version = '1.8.20'
gradle.ext.kotlin_language_version = '1.8'
import java.util.concurrent.TimeUnit
import kotlin.test.Test
import org.junit.jupiter.api.Timeout
...
@Test
@Timeout(MYPYC_TIMEOUT_SECONDS, unit = TimeUnit.SECONDS)
fun myTest() ...
...
internal const val MYPYC_TIMEOUT_SECONDS = 300L
When I run that test, it seems to timeout right around the 45 second mark.
Oddly, that is longer than what seems to be the default.
subprojects {
tasks.withType(Test).configureEach {
useJUnitPlatform()
systemProperties = [
// https://junit.org/junit5/docs/current/user-guide/#writing-tests-declarative-timeouts-default-timeouts
// Global default for test timeout
'junit.jupiter.execution.timeout.default': '30s',
// https://junit.org/junit5/docs/current/user-guide/#writing-tests-declarative-timeouts-mode
// Disable test timeout when the debugger is running
'junit.jupiter.execution.timeout.mode' : 'disabled_on_debug',
]
}
...
}