aboutsummaryrefslogtreecommitdiffstats
path: root/kotlinx-coroutines-debug/test/junit5/CoroutinesTimeoutSimpleTest.kt
blob: 513a8846016008f0e36b2492ca5041d7cb5ce537 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package kotlinx.coroutines.debug.junit5

import kotlinx.coroutines.*
import org.junit.jupiter.api.*

/**
 * Tests the basic usage of [CoroutinesTimeout] on classes and test methods.
 *
 * This test class is not intended to be run manually. Instead, use [CoroutinesTimeoutTest] as the entry point.
 */
@TestMethodOrder(MethodOrderer.OrderAnnotation::class)
@CoroutinesTimeout(100)
class CoroutinesTimeoutSimpleTest {

    @Test
    @Order(1)
    fun usesClassTimeout1() {
        runBlocking {
            delay(150)
        }
    }

    @CoroutinesTimeout(1000)
    @Test
    @Order(2)
    fun ignoresClassTimeout() {
        runBlocking {
            delay(150)
        }
    }

    @CoroutinesTimeout(200)
    @Test
    @Order(3)
    fun usesMethodTimeout() {
        runBlocking {
            delay(300)
        }
    }

    @Test
    @Order(4)
    fun fitsInClassTimeout() {
        runBlocking {
            delay(50)
        }
    }

    @Test
    @Order(5)
    fun usesClassTimeout2() {
        runBlocking {
            delay(150)
        }
    }

}