When using `testApplication`, should I wrap it in ...
# ktor
u
When using
testApplication
, should I wrap it in
runTest { .. }
or not? Both seem to work
Copy code
@Test fun foo() = runTest {
	testApplication {
		//
	}
}
vs
Copy code
@Test fun foo() = testApplication {
	//
}
e
Hey, it's fine to just use
testApplication
u
But if I need to access some field that
runTest
lambda provides, is it safe to be wrapped? Say something like this
Copy code
@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
Okay now I'm seeing its wrapping
runTest
inside, its just that
TestScope
reference is not available..
h
Ktor does not support delay skipping nor really injecting a different scope/dispatcher.
u
what do you mean? I'm looking inside testApplication and its wrapping runTest
h
Oh sorry, should take a look first. Nice to see it is finally supported