• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package kotlinx.coroutines.debug.junit5
2 
3 import kotlinx.coroutines.testing.*
4 import kotlinx.coroutines.*
5 import org.junit.jupiter.api.*
6 
7 /**
8  * Tests that [CoroutinesTimeout] is inherited.
9  *
10  * This test class is not intended to be run manually. Instead, use [CoroutinesTimeoutTest] as the entry point.
11  */
12 class CoroutinesTimeoutInheritanceTest {
13 
14     @CoroutinesTimeout(100)
15     open class Base
16 
17     @TestMethodOrder(MethodOrderer.OrderAnnotation::class)
18     class InheritedWithNoTimeout: Base() {
19 
20         @Test
21         @Order(1)
<lambda>null22         fun usesBaseClassTimeout() = runBlocking {
23             delay(1000)
24         }
25 
26         @CoroutinesTimeout(300)
27         @Test
28         @Order(2)
<lambda>null29         fun methodOverridesBaseClassTimeoutWithGreaterTimeout() = runBlocking {
30             delay(200)
31         }
32 
33         @CoroutinesTimeout(10)
34         @Test
35         @Order(3)
<lambda>null36         fun methodOverridesBaseClassTimeoutWithLesserTimeout() = runBlocking {
37             delay(50)
38         }
39 
40     }
41 
42     @CoroutinesTimeout(300)
43     class InheritedWithGreaterTimeout : TestBase() {
44 
45         @Test
<lambda>null46         fun classOverridesBaseClassTimeout1() = runBlocking {
47             delay(200)
48         }
49 
50         @Test
<lambda>null51         fun classOverridesBaseClassTimeout2() = runBlocking {
52             delay(400)
53         }
54 
55     }
56 
57 }