1 /* 2 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 package kotlinx.coroutines.debug.junit5 6 7 import kotlinx.coroutines.* 8 import org.junit.jupiter.api.* 9 10 /** 11 * Tests that [CoroutinesTimeout] is inherited. 12 * 13 * This test class is not intended to be run manually. Instead, use [CoroutinesTimeoutTest] as the entry point. 14 */ 15 class CoroutinesTimeoutInheritanceTest { 16 17 @CoroutinesTimeout(100) 18 open class Base 19 20 @TestMethodOrder(MethodOrderer.OrderAnnotation::class) 21 class InheritedWithNoTimeout: Base() { 22 23 @Test 24 @Order(1) <lambda>null25 fun usesBaseClassTimeout() = runBlocking { 26 delay(1000) 27 } 28 29 @CoroutinesTimeout(300) 30 @Test 31 @Order(2) <lambda>null32 fun methodOverridesBaseClassTimeoutWithGreaterTimeout() = runBlocking { 33 delay(200) 34 } 35 36 @CoroutinesTimeout(10) 37 @Test 38 @Order(3) <lambda>null39 fun methodOverridesBaseClassTimeoutWithLesserTimeout() = runBlocking { 40 delay(50) 41 } 42 43 } 44 45 @CoroutinesTimeout(300) 46 class InheritedWithGreaterTimeout : TestBase() { 47 48 @Test <lambda>null49 fun classOverridesBaseClassTimeout1() = runBlocking { 50 delay(200) 51 } 52 53 @Test <lambda>null54 fun classOverridesBaseClassTimeout2() = runBlocking { 55 delay(400) 56 } 57 58 } 59 60 }