-
Notifications
You must be signed in to change notification settings - Fork 624
/
ContainerTimeoutTest.kt
36 lines (33 loc) · 1.11 KB
/
ContainerTimeoutTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.sksamuel.kotest.engine.test.timeout
import io.kotest.common.ExperimentalKotest
import io.kotest.core.spec.style.FunSpec
import io.kotest.engine.TestEngineLauncher
import io.kotest.engine.listener.CollectingTestEngineListener
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.delay
import kotlin.time.Duration.Companion.milliseconds
@ExperimentalKotest
class ContainerTimeoutTest : FunSpec() {
init {
test("container test should timeout if nested exceeds parent timeout") {
val collector = CollectingTestEngineListener()
TestEngineLauncher(collector)
.withClasses(NestedTimeout::class)
.launch()
collector.tests.keys.map { it.name.testName }.toSet() shouldBe setOf("a")
collector.tests.values.map { it.errorOrNull?.message }.toSet() shouldBe setOf(
"Test 'a' did not complete within 10ms",
)
}
}
}
@ExperimentalKotest
private class NestedTimeout : FunSpec() {
init {
context("a").config(timeout = 100.milliseconds) {
test("b") {
delay(2000.milliseconds)
}
}
}
}