From a137212a527eec34d1cbe225967a367e78a06fd3 Mon Sep 17 00:00:00 2001 From: Alex Vanyo Date: Mon, 15 May 2023 19:50:29 -0700 Subject: [PATCH] Increase runAppTest timeout --- .../com/alexvanyo/composelife/test/BaseHiltTest.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hilt-test/src/androidMain/kotlin/com/alexvanyo/composelife/test/BaseHiltTest.kt b/hilt-test/src/androidMain/kotlin/com/alexvanyo/composelife/test/BaseHiltTest.kt index cd1078ae02..44a3655365 100644 --- a/hilt-test/src/androidMain/kotlin/com/alexvanyo/composelife/test/BaseHiltTest.kt +++ b/hilt-test/src/androidMain/kotlin/com/alexvanyo/composelife/test/BaseHiltTest.kt @@ -19,7 +19,6 @@ package com.alexvanyo.composelife.test import androidx.test.ext.junit.runners.AndroidJUnit4 import com.alexvanyo.composelife.updatable.Updatable import dagger.hilt.android.testing.HiltAndroidRule -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.launch import kotlinx.coroutines.test.TestResult import kotlinx.coroutines.test.TestScope @@ -30,6 +29,8 @@ import javax.inject.Inject import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext import kotlin.test.BeforeTest +import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds /** * A base class for testing components that depend on Hilt injected classes. @@ -37,7 +38,6 @@ import kotlin.test.BeforeTest * Subclasses must call [runAppTest] instead of [runTest] to properly initialize dependencies. */ @Suppress("UnnecessaryAbstractClass") -@OptIn(ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) abstract class BaseHiltTest { @@ -54,8 +54,12 @@ abstract class BaseHiltTest { fun runAppTest( context: CoroutineContext = EmptyCoroutineContext, + timeout: Duration = 60.seconds, testBody: suspend TestScope.() -> Unit, - ): TestResult = runTest(context) { + ): TestResult = runTest( + context = context, + timeout = timeout, + ) { updatables.forEach { updatable -> backgroundScope.launch { updatable.update()