ursus
08/19/2025, 7:12 PMtestApplication
, should I wrap it in runTest { .. }
or not? Both seem to work
@Test fun foo() = runTest {
testApplication {
//
}
}
vs
@Test fun foo() = testApplication {
//
}
e5l
08/19/2025, 7:12 PMtestApplication
ursus
08/19/2025, 7:14 PMrunTest
lambda provides, is it safe to be wrapped?
Say something like this
@Test
fun foo() = runTest {
val connector = Foo()
turbineScope {
val connectionState = connector.connectionState.testIn(backgroundScope) <----
launch {
connector.connect(ChatConversationId("convo123"))
}
assertThat(connectionState.awaitItem()).isEqualTo(Connecting)
assertThat(connectionState.awaitItem()).isEqualTo(Connected)
}
}
if I were to want to add testApplication
there so connector can work against a real server
What about the other delay skipping features of runTest
ursus
08/19/2025, 7:18 PMrunTest
inside, its just that TestScope
reference is not available..hfhbd
08/19/2025, 8:05 PMursus
08/19/2025, 8:06 PMhfhbd
08/19/2025, 8:11 PM