dmcg
02/11/2020, 1:57 PMdave08
02/11/2020, 2:02 PMsuspend fun calls and flows... the truth is, I'd suppose that surrounding each test with https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/run-blocking-test.html might be enough, but I don't know if that's what everybody might want in every case...dmcg
02/12/2020, 9:09 AMdave08
02/12/2020, 10:49 AMthis or it or are they both being used?dave08
02/12/2020, 10:50 AMthis (the receiver of the lambda) as an object providing a few things, including a call property...dmcg
02/12/2020, 10:51 AMthis for the fixture, it for a TestDescriptor. We could add things to the TestDescriptor, but I’m wary of making changes like that that I can’t back out.dmcg
02/12/2020, 10:51 AMdave08
02/12/2020, 10:53 AMevery { } and coEvery { } for non-coroutines, and coroutines mocking... you could technically have an extra experimental function like that too with a special TestDescriptor for it...dmcg
02/12/2020, 10:54 AMfun test(name: String, f: F.(testDescriptor: TestDescriptor) -> Unit): NodeBuilder<F> =
test_(name) { testDescriptor ->
this.apply {
f(testDescriptor)
}
}dmcg
02/12/2020, 10:56 AMfun test(name: String, f: suspend F.(testDescriptor: TestDescriptor) -> Unit): NodeBuilder<F> =
test_(name) { testDescriptor ->
this.apply {
testDescriptor.coroutineContext.runBlockingTest {
f(testDescriptor)
}
}
}dmcg
02/12/2020, 10:56 AMdmcg
02/12/2020, 10:57 AMdmcg
02/12/2020, 11:01 AMTestCoroutineScope from the testDescriptor in order to call things like advanceTimeBy, in which case just adding your own runBlockingTest is a minor inconvenience?dmcg
02/12/2020, 11:03 AMdave08
02/12/2020, 1:26 PMtestScope on TestDescriptor to avoid having to write all that ...Uberto Barbini
02/13/2020, 9:28 AMdave08
02/13/2020, 11:34 AMI'm struggling to see the use case? Do you write tests for Coroutines? You don't mind having to nest an extra
runBlockingTest { } within each step of the test?dave08
02/13/2020, 11:35 AM@Test fun testSomething() = runBlockingTest { ... } so it's just one level, but in a DSL it makes things VERY hard to read.dave08
02/13/2020, 11:37 AMdmcg
02/13/2020, 11:39 AMUberto Barbini
02/13/2020, 11:49 AM